home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gcc_260.zip / gcc_260 / reload.c < prev    next >
C/C++ Source or Header  |  1994-07-12  |  189KB  |  5,651 lines

  1. /* Search an insn for pseudo regs that must be in hard regs and are not.
  2.    Copyright (C) 1987, 88, 89, 92, 93, 1994 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* This file contains subroutines used only from the file reload1.c.
  22.    It knows how to scan one insn for operands and values
  23.    that need to be copied into registers to make valid code.
  24.    It also finds other operands and values which are valid
  25.    but for which equivalent values in registers exist and
  26.    ought to be used instead.
  27.  
  28.    Before processing the first insn of the function, call `init_reload'.
  29.  
  30.    To scan an insn, call `find_reloads'.  This does two things:
  31.    1. sets up tables describing which values must be reloaded
  32.    for this insn, and what kind of hard regs they must be reloaded into;
  33.    2. optionally record the locations where those values appear in
  34.    the data, so they can be replaced properly later.
  35.    This is done only if the second arg to `find_reloads' is nonzero.
  36.  
  37.    The third arg to `find_reloads' specifies the number of levels
  38.    of indirect addressing supported by the machine.  If it is zero,
  39.    indirect addressing is not valid.  If it is one, (MEM (REG n))
  40.    is valid even if (REG n) did not get a hard register; if it is two,
  41.    (MEM (MEM (REG n))) is also valid even if (REG n) did not get a
  42.    hard register, and similarly for higher values.
  43.  
  44.    Then you must choose the hard regs to reload those pseudo regs into,
  45.    and generate appropriate load insns before this insn and perhaps
  46.    also store insns after this insn.  Set up the array `reload_reg_rtx'
  47.    to contain the REG rtx's for the registers you used.  In some
  48.    cases `find_reloads' will return a nonzero value in `reload_reg_rtx'
  49.    for certain reloads.  Then that tells you which register to use,
  50.    so you do not need to allocate one.  But you still do need to add extra
  51.    instructions to copy the value into and out of that register.
  52.  
  53.    Finally you must call `subst_reloads' to substitute the reload reg rtx's
  54.    into the locations already recorded.
  55.  
  56. NOTE SIDE EFFECTS:
  57.  
  58.    find_reloads can alter the operands of the instruction it is called on.
  59.  
  60.    1. Two operands of any sort may be interchanged, if they are in a
  61.    commutative instruction.
  62.    This happens only if find_reloads thinks the instruction will compile
  63.    better that way.
  64.  
  65.    2. Pseudo-registers that are equivalent to constants are replaced
  66.    with those constants if they are not in hard registers.
  67.  
  68. 1 happens every time find_reloads is called.
  69. 2 happens only when REPLACE is 1, which is only when
  70. actually doing the reloads, not when just counting them.
  71.  
  72.  
  73. Using a reload register for several reloads in one insn:
  74.  
  75. When an insn has reloads, it is considered as having three parts:
  76. the input reloads, the insn itself after reloading, and the output reloads.
  77. Reloads of values used in memory addresses are often needed for only one part.
  78.  
  79. When this is so, reload_when_needed records which part needs the reload.
  80. Two reloads for different parts of the insn can share the same reload
  81. register.
  82.  
  83. When a reload is used for addresses in multiple parts, or when it is
  84. an ordinary operand, it is classified as RELOAD_OTHER, and cannot share
  85. a register with any other reload.  */
  86.  
  87. #define REG_OK_STRICT
  88.  
  89. #include "config.h"
  90. #include "rtl.h"
  91. #include "insn-config.h"
  92. #include "insn-codes.h"
  93. #include "recog.h"
  94. #include "reload.h"
  95. #include "regs.h"
  96. #include "hard-reg-set.h"
  97. #include "flags.h"
  98. #include "real.h"
  99.  
  100. #ifndef REGISTER_MOVE_COST
  101. #define REGISTER_MOVE_COST(x, y) 2
  102. #endif
  103.  
  104. /* The variables set up by `find_reloads' are:
  105.  
  106.    n_reloads          number of distinct reloads needed; max reload # + 1
  107.        tables indexed by reload number
  108.    reload_in          rtx for value to reload from
  109.    reload_out          rtx for where to store reload-reg afterward if nec
  110.                (often the same as reload_in)
  111.    reload_reg_class      enum reg_class, saying what regs to reload into
  112.    reload_inmode      enum machine_mode; mode this operand should have
  113.                when reloaded, on input.
  114.    reload_outmode      enum machine_mode; mode this operand should have
  115.                when reloaded, on output.
  116.    reload_optional      char, nonzero for an optional reload.
  117.                Optional reloads are ignored unless the
  118.                value is already sitting in a register.
  119.    reload_inc          int, positive amount to increment or decrement by if
  120.                reload_in is a PRE_DEC, PRE_INC, POST_DEC, POST_INC.
  121.                Ignored otherwise (don't assume it is zero).
  122.    reload_in_reg      rtx.  A reg for which reload_in is the equivalent.
  123.                If reload_in is a symbol_ref which came from
  124.                reg_equiv_constant, then this is the pseudo
  125.                which has that symbol_ref as equivalent.
  126.    reload_reg_rtx      rtx.  This is the register to reload into.
  127.                If it is zero when `find_reloads' returns,
  128.                you must find a suitable register in the class
  129.                specified by reload_reg_class, and store here
  130.                an rtx for that register with mode from
  131.                reload_inmode or reload_outmode.
  132.    reload_nocombine      char, nonzero if this reload shouldn't be
  133.                combined with another reload.
  134.    reload_opnum          int, operand number being reloaded.  This is
  135.                used to group related reloads and need not always
  136.                be equal to the actual operand number in the insn,
  137.                though it current will be; for in-out operands, it
  138.                is one of the two operand numbers.
  139.    reload_when_needed    enum, classifies reload as needed either for
  140.                addressing an input reload, addressing an output,
  141.                for addressing a non-reloaded mem ref,
  142.                or for unspecified purposes (i.e., more than one
  143.                of the above).
  144.    reload_secondary_p      int, 1 if this is a secondary register for one
  145.                or more reloads.
  146.    reload_secondary_in_reload
  147.    reload_secondary_out_reload
  148.                  int, gives the reload number of a secondary
  149.                reload, when needed; otherwise -1
  150.    reload_secondary_in_icode
  151.    reload_secondary_out_icode
  152.               enum insn_code, if a secondary reload is required,
  153.                gives the INSN_CODE that uses the secondary
  154.                reload as a scratch register, or CODE_FOR_nothing
  155.                if the secondary reload register is to be an
  156.                intermediate register.  */
  157. int n_reloads;
  158.  
  159. rtx reload_in[MAX_RELOADS];
  160. rtx reload_out[MAX_RELOADS];
  161. enum reg_class reload_reg_class[MAX_RELOADS];
  162. enum machine_mode reload_inmode[MAX_RELOADS];
  163. enum machine_mode reload_outmode[MAX_RELOADS];
  164. rtx reload_reg_rtx[MAX_RELOADS];
  165. char reload_optional[MAX_RELOADS];
  166. int reload_inc[MAX_RELOADS];
  167. rtx reload_in_reg[MAX_RELOADS];
  168. char reload_nocombine[MAX_RELOADS];
  169. int reload_opnum[MAX_RELOADS];
  170. enum reload_type reload_when_needed[MAX_RELOADS];
  171. int reload_secondary_p[MAX_RELOADS];
  172. int reload_secondary_in_reload[MAX_RELOADS];
  173. int reload_secondary_out_reload[MAX_RELOADS];
  174. enum insn_code reload_secondary_in_icode[MAX_RELOADS];
  175. enum insn_code reload_secondary_out_icode[MAX_RELOADS];
  176.  
  177. /* All the "earlyclobber" operands of the current insn
  178.    are recorded here.  */
  179. int n_earlyclobbers;
  180. rtx reload_earlyclobbers[MAX_RECOG_OPERANDS];
  181.  
  182. int reload_n_operands;
  183.  
  184. /* Replacing reloads.
  185.  
  186.    If `replace_reloads' is nonzero, then as each reload is recorded
  187.    an entry is made for it in the table `replacements'.
  188.    Then later `subst_reloads' can look through that table and
  189.    perform all the replacements needed.  */
  190.  
  191. /* Nonzero means record the places to replace.  */
  192. static int replace_reloads;
  193.  
  194. /* Each replacement is recorded with a structure like this.  */
  195. struct replacement
  196. {
  197.   rtx *where;            /* Location to store in */
  198.   rtx *subreg_loc;        /* Location of SUBREG if WHERE is inside
  199.                    a SUBREG; 0 otherwise.  */
  200.   int what;            /* which reload this is for */
  201.   enum machine_mode mode;    /* mode it must have */
  202. };
  203.  
  204. static struct replacement replacements[MAX_RECOG_OPERANDS * ((MAX_REGS_PER_ADDRESS * 2) + 1)];
  205.  
  206. /* Number of replacements currently recorded.  */
  207. static int n_replacements;
  208.  
  209. /* Used to track what is modified by an operand.  */
  210. struct decomposition
  211. {
  212.   int reg_flag;        /* Nonzero if referencing a register. */
  213.   int safe;        /* Nonzero if this can't conflict with anything. */
  214.   rtx base;        /* Base adddress for MEM. */
  215.   HOST_WIDE_INT start;    /* Starting offset or register number. */
  216.   HOST_WIDE_INT end;    /* Endinf offset or register number.  */
  217. };
  218.  
  219. /* MEM-rtx's created for pseudo-regs in stack slots not directly addressable;
  220.    (see reg_equiv_address).  */
  221. static rtx memlocs[MAX_RECOG_OPERANDS * ((MAX_REGS_PER_ADDRESS * 2) + 1)];
  222. static int n_memlocs;
  223.  
  224. #ifdef SECONDARY_MEMORY_NEEDED
  225.  
  226. /* Save MEMs needed to copy from one class of registers to another.  One MEM
  227.    is used per mode, but normally only one or two modes are ever used.  
  228.  
  229.    We keep two versions, before and after register elimination.  The one 
  230.    after register elimination is record separately for each operand.  This
  231.    is done in case the address is not valid to be sure that we separately
  232.    reload each.  */
  233.  
  234. static rtx secondary_memlocs[NUM_MACHINE_MODES];
  235. static rtx secondary_memlocs_elim[NUM_MACHINE_MODES][MAX_RECOG_OPERANDS];
  236. #endif
  237.  
  238. /* The instruction we are doing reloads for;
  239.    so we can test whether a register dies in it.  */
  240. static rtx this_insn;
  241.  
  242. /* Nonzero if this instruction is a user-specified asm with operands.  */
  243. static int this_insn_is_asm;
  244.  
  245. /* If hard_regs_live_known is nonzero,
  246.    we can tell which hard regs are currently live,
  247.    at least enough to succeed in choosing dummy reloads.  */
  248. static int hard_regs_live_known;
  249.  
  250. /* Indexed by hard reg number,
  251.    element is nonegative if hard reg has been spilled.
  252.    This vector is passed to `find_reloads' as an argument
  253.    and is not changed here.  */
  254. static short *static_reload_reg_p;
  255.  
  256. /* Set to 1 in subst_reg_equivs if it changes anything.  */
  257. static int subst_reg_equivs_changed;
  258.  
  259. /* On return from push_reload, holds the reload-number for the OUT
  260.    operand, which can be different for that from the input operand.  */
  261. static int output_reloadnum;
  262.  
  263.   /* Compare two RTX's.  */
  264. #define MATCHES(x, y) \
  265.  (x == y || (x != 0 && (GET_CODE (x) == REG                \
  266.             ? GET_CODE (y) == REG && REGNO (x) == REGNO (y)    \
  267.             : rtx_equal_p (x, y) && ! side_effects_p (x))))
  268.  
  269.   /* Indicates if two reloads purposes are for similar enough things that we
  270.      can merge their reloads.  */
  271. #define MERGABLE_RELOADS(when1, when2, op1, op2) \
  272.   ((when1) == RELOAD_OTHER || (when2) == RELOAD_OTHER    \
  273.    || ((when1) == (when2) && (op1) == (op2))        \
  274.    || ((when1) == RELOAD_FOR_INPUT && (when2) == RELOAD_FOR_INPUT) \
  275.    || ((when1) == RELOAD_FOR_OPERAND_ADDRESS        \
  276.        && (when2) == RELOAD_FOR_OPERAND_ADDRESS)    \
  277.    || ((when1) == RELOAD_FOR_OTHER_ADDRESS        \
  278.        && (when2) == RELOAD_FOR_OTHER_ADDRESS))
  279.  
  280.   /* Nonzero if these two reload purposes produce RELOAD_OTHER when merged.  */
  281. #define MERGE_TO_OTHER(when1, when2, op1, op2) \
  282.   ((when1) != (when2)                    \
  283.    || ! ((op1) == (op2)                    \
  284.      || (when1) == RELOAD_FOR_INPUT            \
  285.      || (when1) == RELOAD_FOR_OPERAND_ADDRESS    \
  286.      || (when1) == RELOAD_FOR_OTHER_ADDRESS))
  287.  
  288. static int push_secondary_reload PROTO((int, rtx, int, int, enum reg_class,
  289.                     enum machine_mode, enum reload_type,
  290.                     enum insn_code *));
  291. static int push_reload        PROTO((rtx, rtx, rtx *, rtx *, enum reg_class,
  292.                        enum machine_mode, enum machine_mode,
  293.                        int, int, int, enum reload_type));
  294. static void push_replacement    PROTO((rtx *, int, enum machine_mode));
  295. static void combine_reloads    PROTO((void));
  296. static rtx find_dummy_reload    PROTO((rtx, rtx, rtx *, rtx *,
  297.                        enum machine_mode, enum machine_mode,
  298.                        enum reg_class, int));
  299. static int earlyclobber_operand_p PROTO((rtx));
  300. static int hard_reg_set_here_p    PROTO((int, int, rtx));
  301. static struct decomposition decompose PROTO((rtx));
  302. static int immune_p        PROTO((rtx, rtx, struct decomposition));
  303. static int alternative_allows_memconst PROTO((char *, int));
  304. static rtx find_reloads_toplev    PROTO((rtx, int, enum reload_type, int, int));
  305. static rtx make_memloc        PROTO((rtx, int));
  306. static int find_reloads_address    PROTO((enum machine_mode, rtx *, rtx, rtx *,
  307.                        int, enum reload_type, int));
  308. static rtx subst_reg_equivs    PROTO((rtx));
  309. static rtx subst_indexed_address PROTO((rtx));
  310. static int find_reloads_address_1 PROTO((rtx, int, rtx *, int,
  311.                      enum reload_type,int));
  312. static void find_reloads_address_part PROTO((rtx, rtx *, enum reg_class,
  313.                          enum machine_mode, int,
  314.                          enum reload_type, int));
  315. static int find_inc_amount    PROTO((rtx, rtx));
  316.  
  317. #ifdef HAVE_SECONDARY_RELOADS
  318.  
  319. /* Determine if any secondary reloads are needed for loading (if IN_P is
  320.    non-zero) or storing (if IN_P is zero) X to or from a reload register of
  321.    register class RELOAD_CLASS in mode RELOAD_MODE.  If secondary reloads
  322.    are needed, push them.
  323.  
  324.    Return the reload number of the secondary reload we made, or -1 if
  325.    we didn't need one.  *PICODE is set to the insn_code to use if we do
  326.    need a secondary reload.  */
  327.  
  328. static int
  329. push_secondary_reload (in_p, x, opnum, optional, reload_class, reload_mode,
  330.                type, picode)
  331.      int in_p;
  332.      rtx x;
  333.      int opnum;
  334.      int optional;
  335.      enum reg_class reload_class;
  336.      enum machine_mode reload_mode;
  337.      enum reload_type type;
  338.      enum insn_code *picode;
  339. {
  340.   enum reg_class class = NO_REGS;
  341.   enum machine_mode mode = reload_mode;
  342.   enum insn_code icode = CODE_FOR_nothing;
  343.   enum reg_class t_class = NO_REGS;
  344.   enum machine_mode t_mode = VOIDmode;
  345.   enum insn_code t_icode = CODE_FOR_nothing;
  346.   enum reload_type secondary_type;
  347.   int i;
  348.   int s_reload, t_reload = -1;
  349.  
  350.   if (type == RELOAD_FOR_INPUT_ADDRESS || type == RELOAD_FOR_OUTPUT_ADDRESS)
  351.     secondary_type = type;
  352.   else
  353.     secondary_type = in_p ? RELOAD_FOR_INPUT_ADDRESS : RELOAD_FOR_OUTPUT_ADDRESS;
  354.  
  355.   *picode = CODE_FOR_nothing;
  356.  
  357.   /* If X is a pseudo-register that has an equivalent MEM (actually, if it
  358.      is still a pseudo-register by now, it *must* have an equivalent MEM
  359.      but we don't want to assume that), use that equivalent when seeing if
  360.      a secondary reload is needed since whether or not a reload is needed
  361.      might be sensitive to the form of the MEM.  */
  362.  
  363.   if (GET_CODE (x) == REG && REGNO (x) >= FIRST_PSEUDO_REGISTER
  364.       && reg_equiv_mem[REGNO (x)] != 0)
  365.     x = reg_equiv_mem[REGNO (x)];
  366.  
  367. #ifdef SECONDARY_INPUT_RELOAD_CLASS
  368.   if (in_p)
  369.     class = SECONDARY_INPUT_RELOAD_CLASS (reload_class, reload_mode, x);
  370. #endif
  371.  
  372. #ifdef SECONDARY_OUTPUT_RELOAD_CLASS
  373.   if (! in_p)
  374.     class = SECONDARY_OUTPUT_RELOAD_CLASS (reload_class, reload_mode, x);
  375. #endif
  376.  
  377.   /* If we don't need any secondary registers, done.  */
  378.   if (class == NO_REGS)
  379.     return -1;
  380.  
  381.   /* Get a possible insn to use.  If the predicate doesn't accept X, don't
  382.      use the insn.  */
  383.  
  384.   icode = (in_p ? reload_in_optab[(int) reload_mode]
  385.        : reload_out_optab[(int) reload_mode]);
  386.  
  387.   if (icode != CODE_FOR_nothing
  388.       && insn_operand_predicate[(int) icode][in_p]
  389.       && (! (insn_operand_predicate[(int) icode][in_p]) (x, reload_mode)))
  390.     icode = CODE_FOR_nothing;
  391.  
  392.   /* If we will be using an insn, see if it can directly handle the reload
  393.      register we will be using.  If it can, the secondary reload is for a
  394.      scratch register.  If it can't, we will use the secondary reload for
  395.      an intermediate register and require a tertiary reload for the scratch
  396.      register.  */
  397.  
  398.   if (icode != CODE_FOR_nothing)
  399.     {
  400.       /* If IN_P is non-zero, the reload register will be the output in 
  401.      operand 0.  If IN_P is zero, the reload register will be the input
  402.      in operand 1.  Outputs should have an initial "=", which we must
  403.      skip.  */
  404.  
  405.       char insn_letter = insn_operand_constraint[(int) icode][!in_p][in_p];
  406.       enum reg_class insn_class
  407.     = (insn_letter == 'r' ? GENERAL_REGS
  408.        : REG_CLASS_FROM_LETTER (insn_letter));
  409.  
  410.       if (insn_class == NO_REGS
  411.       || (in_p && insn_operand_constraint[(int) icode][!in_p][0] != '=')
  412.       /* The scratch register's constraint must start with "=&".  */
  413.       || insn_operand_constraint[(int) icode][2][0] != '='
  414.       || insn_operand_constraint[(int) icode][2][1] != '&')
  415.     abort ();
  416.  
  417.       if (reg_class_subset_p (reload_class, insn_class))
  418.     mode = insn_operand_mode[(int) icode][2];
  419.       else
  420.     {
  421.       char t_letter = insn_operand_constraint[(int) icode][2][2];
  422.       class = insn_class;
  423.       t_mode = insn_operand_mode[(int) icode][2];
  424.       t_class = (t_letter == 'r' ? GENERAL_REGS
  425.              : REG_CLASS_FROM_LETTER (t_letter));
  426.       t_icode = icode;
  427.       icode = CODE_FOR_nothing;
  428.     }
  429.     }
  430.  
  431.   /* This case isn't valid, so fail.  Reload is allowed to use the same
  432.      register for RELOAD_FOR_INPUT_ADDRESS and RELOAD_FOR_INPUT reloads, but
  433.      in the case of a secondary register, we actually need two different
  434.      registers for correct code.  We fail here to prevent the possibility of
  435.      silently generating incorrect code later.
  436.  
  437.      The convention is that secondary input reloads are valid only if the
  438.      secondary_class is different from class.  If you have such a case, you
  439.      can not use secondary reloads, you must work around the problem some
  440.      other way.
  441.  
  442.      Allow this when MODE is not reload_mode and assume that the generated
  443.      code handles this case (it does on the Alpha, which is the only place
  444.      this currently happens).  */
  445.  
  446.   if (in_p && class == reload_class && mode == reload_mode)
  447.     abort ();
  448.  
  449.   /* If we need a tertiary reload, see if we have one we can reuse or else
  450.      make a new one.  */
  451.  
  452.   if (t_class != NO_REGS)
  453.     {
  454.       for (t_reload = 0; t_reload < n_reloads; t_reload++)
  455.     if (reload_secondary_p[t_reload]
  456.         && (reg_class_subset_p (t_class, reload_reg_class[t_reload])
  457.         || reg_class_subset_p (reload_reg_class[t_reload], t_class))
  458.         && ((in_p && reload_inmode[t_reload] == t_mode)
  459.         || (! in_p && reload_outmode[t_reload] == t_mode))
  460.         && ((in_p && (reload_secondary_in_icode[t_reload]
  461.               == CODE_FOR_nothing))
  462.         || (! in_p &&(reload_secondary_out_icode[t_reload]
  463.                   == CODE_FOR_nothing)))
  464.         && (reg_class_size[(int) t_class] == 1
  465. #ifdef SMALL_REGISTER_CLASSES
  466.         || 1
  467. #endif
  468.         )
  469.         && MERGABLE_RELOADS (secondary_type,
  470.                  reload_when_needed[t_reload],
  471.                  opnum, reload_opnum[t_reload]))
  472.       {
  473.         if (in_p)
  474.           reload_inmode[t_reload] = t_mode;
  475.         if (! in_p)
  476.           reload_outmode[t_reload] = t_mode;
  477.  
  478.         if (reg_class_subset_p (t_class, reload_reg_class[t_reload]))
  479.           reload_reg_class[t_reload] = t_class;
  480.  
  481.         reload_opnum[t_reload] = MIN (reload_opnum[t_reload], opnum);
  482.         reload_optional[t_reload] &= optional;
  483.         reload_secondary_p[t_reload] = 1;
  484.         if (MERGE_TO_OTHER (secondary_type, reload_when_needed[t_reload],
  485.                 opnum, reload_opnum[t_reload]))
  486.           reload_when_needed[t_reload] = RELOAD_OTHER;
  487.       }
  488.  
  489.       if (t_reload == n_reloads)
  490.     {
  491.       /* We need to make a new tertiary reload for this register class.  */
  492.       reload_in[t_reload] = reload_out[t_reload] = 0;
  493.       reload_reg_class[t_reload] = t_class;
  494.       reload_inmode[t_reload] = in_p ? t_mode : VOIDmode;
  495.       reload_outmode[t_reload] = ! in_p ? t_mode : VOIDmode;
  496.       reload_reg_rtx[t_reload] = 0;
  497.       reload_optional[t_reload] = optional;
  498.       reload_inc[t_reload] = 0;
  499.       /* Maybe we could combine these, but it seems too tricky.  */
  500.       reload_nocombine[t_reload] = 1;
  501.       reload_in_reg[t_reload] = 0;
  502.       reload_opnum[t_reload] = opnum;
  503.       reload_when_needed[t_reload] = secondary_type;
  504.       reload_secondary_in_reload[t_reload] = -1;
  505.       reload_secondary_out_reload[t_reload] = -1;
  506.       reload_secondary_in_icode[t_reload] = CODE_FOR_nothing;
  507.       reload_secondary_out_icode[t_reload] = CODE_FOR_nothing;
  508.       reload_secondary_p[t_reload] = 1;
  509.  
  510.       n_reloads++;
  511.     }
  512.     }
  513.  
  514.   /* See if we can reuse an existing secondary reload.  */
  515.   for (s_reload = 0; s_reload < n_reloads; s_reload++)
  516.     if (reload_secondary_p[s_reload]
  517.     && (reg_class_subset_p (class, reload_reg_class[s_reload])
  518.         || reg_class_subset_p (reload_reg_class[s_reload], class))
  519.     && ((in_p && reload_inmode[s_reload] == mode)
  520.         || (! in_p && reload_outmode[s_reload] == mode))
  521.     && ((in_p && reload_secondary_in_reload[s_reload] == t_reload)
  522.         || (! in_p && reload_secondary_out_reload[s_reload] == t_reload))
  523.     && ((in_p && reload_secondary_in_icode[s_reload] == t_icode)
  524.         || (! in_p && reload_secondary_out_icode[s_reload] == t_icode))
  525.     && (reg_class_size[(int) class] == 1
  526. #ifdef SMALL_REGISTER_CLASSES
  527.         || 1
  528. #endif
  529.         )
  530.     && MERGABLE_RELOADS (secondary_type, reload_when_needed[s_reload],
  531.                  opnum, reload_opnum[s_reload]))
  532.       {
  533.     if (in_p)
  534.       reload_inmode[s_reload] = mode;
  535.     if (! in_p)
  536.       reload_outmode[s_reload] = mode;
  537.  
  538.     if (reg_class_subset_p (class, reload_reg_class[s_reload]))
  539.       reload_reg_class[s_reload] = class;
  540.  
  541.     reload_opnum[s_reload] = MIN (reload_opnum[s_reload], opnum);
  542.     reload_optional[s_reload] &= optional;
  543.     reload_secondary_p[s_reload] = 1;
  544.     if (MERGE_TO_OTHER (secondary_type, reload_when_needed[s_reload],
  545.                 opnum, reload_opnum[s_reload]))
  546.       reload_when_needed[s_reload] = RELOAD_OTHER;
  547.       }
  548.  
  549.   if (s_reload == n_reloads)
  550.     {
  551.       /* We need to make a new secondary reload for this register class.  */
  552.       reload_in[s_reload] = reload_out[s_reload] = 0;
  553.       reload_reg_class[s_reload] = class;
  554.  
  555.       reload_inmode[s_reload] = in_p ? mode : VOIDmode;
  556.       reload_outmode[s_reload] = ! in_p ? mode : VOIDmode;
  557.       reload_reg_rtx[s_reload] = 0;
  558.       reload_optional[s_reload] = optional;
  559.       reload_inc[s_reload] = 0;
  560.       /* Maybe we could combine these, but it seems too tricky.  */
  561.       reload_nocombine[s_reload] = 1;
  562.       reload_in_reg[s_reload] = 0;
  563.       reload_opnum[s_reload] = opnum;
  564.       reload_when_needed[s_reload] = secondary_type;
  565.       reload_secondary_in_reload[s_reload] = in_p ? t_reload : -1;
  566.       reload_secondary_out_reload[s_reload] = ! in_p ? t_reload : -1;
  567.       reload_secondary_in_icode[s_reload] = in_p ? t_icode : CODE_FOR_nothing; 
  568.       reload_secondary_out_icode[s_reload]
  569.     = ! in_p ? t_icode : CODE_FOR_nothing;
  570.       reload_secondary_p[s_reload] = 1;
  571.  
  572.       n_reloads++;
  573.  
  574. #ifdef SECONDARY_MEMORY_NEEDED
  575.       /* If we need a memory location to copy between the two reload regs,
  576.      set it up now.  */
  577.  
  578.       if (in_p && icode == CODE_FOR_nothing
  579.       && SECONDARY_MEMORY_NEEDED (class, reload_class, reload_mode))
  580.     get_secondary_mem (x, reload_mode, opnum, type);
  581.  
  582.       if (! in_p && icode == CODE_FOR_nothing
  583.       && SECONDARY_MEMORY_NEEDED (reload_class, class, reload_mode))
  584.     get_secondary_mem (x, reload_mode, opnum, type);
  585. #endif
  586.     }
  587.  
  588.   *picode = icode;
  589.   return s_reload;
  590. }
  591. #endif /* HAVE_SECONDARY_RELOADS */
  592.  
  593. #ifdef SECONDARY_MEMORY_NEEDED
  594.  
  595. /* Return a memory location that will be used to copy X in mode MODE.  
  596.    If we haven't already made a location for this mode in this insn,
  597.    call find_reloads_address on the location being returned.  */
  598.  
  599. rtx
  600. get_secondary_mem (x, mode, opnum, type)
  601.      rtx x;
  602.      enum machine_mode mode;
  603.      int opnum;
  604.      enum reload_type type;
  605. {
  606.   rtx loc;
  607.   int mem_valid;
  608.  
  609.   /* By default, if MODE is narrower than a word, widen it to a word.
  610.      This is required because most machines that require these memory
  611.      locations do not support short load and stores from all registers
  612.      (e.g., FP registers).  */
  613.  
  614. #ifdef SECONDARY_MEMORY_NEEDED_MODE
  615.   mode = SECONDARY_MEMORY_NEEDED_MODE (mode);
  616. #else
  617.   if (GET_MODE_BITSIZE (mode) < BITS_PER_WORD)
  618.     mode = mode_for_size (BITS_PER_WORD, GET_MODE_CLASS (mode), 0);
  619. #endif
  620.  
  621.   /* If we already have made a MEM for this operand in MODE, return it.  */
  622.   if (secondary_memlocs_elim[(int) mode][opnum] != 0)
  623.     return secondary_memlocs_elim[(int) mode][opnum];
  624.  
  625.   /* If this is the first time we've tried to get a MEM for this mode, 
  626.      allocate a new one.  `something_changed' in reload will get set
  627.      by noticing that the frame size has changed.  */
  628.  
  629.   if (secondary_memlocs[(int) mode] == 0)
  630.     {
  631. #ifdef SECONDARY_MEMORY_NEEDED_RTX
  632.       secondary_memlocs[(int) mode] = SECONDARY_MEMORY_NEEDED_RTX (mode);
  633. #else
  634.       secondary_memlocs[(int) mode]
  635.     = assign_stack_local (mode, GET_MODE_SIZE (mode), 0);
  636. #endif
  637.     }
  638.  
  639.   /* Get a version of the address doing any eliminations needed.  If that
  640.      didn't give us a new MEM, make a new one if it isn't valid.  */
  641.  
  642.   loc = eliminate_regs (secondary_memlocs[(int) mode], VOIDmode, NULL_RTX);
  643.   mem_valid = strict_memory_address_p (mode, XEXP (loc, 0));
  644.  
  645.   if (! mem_valid && loc == secondary_memlocs[(int) mode])
  646.     loc = copy_rtx (loc);
  647.  
  648.   /* The only time the call below will do anything is if the stack
  649.      offset is too large.  In that case IND_LEVELS doesn't matter, so we
  650.      can just pass a zero.  Adjust the type to be the address of the
  651.      corresponding object.  If the address was valid, save the eliminated
  652.      address.  If it wasn't valid, we need to make a reload each time, so
  653.      don't save it.  */
  654.  
  655.   if (! mem_valid)
  656.     {
  657.       type =  (type == RELOAD_FOR_INPUT ? RELOAD_FOR_INPUT_ADDRESS
  658.            : type == RELOAD_FOR_OUTPUT ? RELOAD_FOR_OUTPUT_ADDRESS
  659.            : RELOAD_OTHER);
  660.  
  661.       find_reloads_address (mode, NULL_PTR, XEXP (loc, 0), &XEXP (loc, 0),
  662.                 opnum, type, 0);
  663.     }
  664.  
  665.   secondary_memlocs_elim[(int) mode][opnum] = loc;
  666.   return loc;
  667. }
  668.  
  669. /* Clear any secondary memory locations we've made.  */
  670.  
  671. void
  672. clear_secondary_mem ()
  673. {
  674.   bzero ((char *) secondary_memlocs, sizeof secondary_memlocs);
  675. }
  676. #endif /* SECONDARY_MEMORY_NEEDED */
  677.  
  678. /* Record one reload that needs to be performed.
  679.    IN is an rtx saying where the data are to be found before this instruction.
  680.    OUT says where they must be stored after the instruction.
  681.    (IN is zero for data not read, and OUT is zero for data not written.)
  682.    INLOC and OUTLOC point to the places in the instructions where
  683.    IN and OUT were found.
  684.    If IN and OUT are both non-zero, it means the same register must be used
  685.    to reload both IN and OUT.
  686.  
  687.    CLASS is a register class required for the reloaded data.
  688.    INMODE is the machine mode that the instruction requires
  689.    for the reg that replaces IN and OUTMODE is likewise for OUT.
  690.  
  691.    If IN is zero, then OUT's location and mode should be passed as
  692.    INLOC and INMODE.
  693.  
  694.    STRICT_LOW is the 1 if there is a containing STRICT_LOW_PART rtx.
  695.  
  696.    OPTIONAL nonzero means this reload does not need to be performed:
  697.    it can be discarded if that is more convenient.
  698.  
  699.    OPNUM and TYPE say what the purpose of this reload is.
  700.  
  701.    The return value is the reload-number for this reload.
  702.  
  703.    If both IN and OUT are nonzero, in some rare cases we might
  704.    want to make two separate reloads.  (Actually we never do this now.)
  705.    Therefore, the reload-number for OUT is stored in
  706.    output_reloadnum when we return; the return value applies to IN.
  707.    Usually (presently always), when IN and OUT are nonzero,
  708.    the two reload-numbers are equal, but the caller should be careful to
  709.    distinguish them.  */
  710.  
  711. static int
  712. push_reload (in, out, inloc, outloc, class,
  713.          inmode, outmode, strict_low, optional, opnum, type)
  714.      register rtx in, out;
  715.      rtx *inloc, *outloc;
  716.      enum reg_class class;
  717.      enum machine_mode inmode, outmode;
  718.      int strict_low;
  719.      int optional;
  720.      int opnum;
  721.      enum reload_type type;
  722. {
  723.   register int i;
  724.   int dont_share = 0;
  725.   rtx *in_subreg_loc = 0, *out_subreg_loc = 0;
  726.   int secondary_in_reload = -1, secondary_out_reload = -1;
  727.   enum insn_code secondary_in_icode, secondary_out_icode;
  728.  
  729.   /* INMODE and/or OUTMODE could be VOIDmode if no mode
  730.      has been specified for the operand.  In that case,
  731.      use the operand's mode as the mode to reload.  */
  732.   if (inmode == VOIDmode && in != 0)
  733.     inmode = GET_MODE (in);
  734.   if (outmode == VOIDmode && out != 0)
  735.     outmode = GET_MODE (out);
  736.  
  737.   /* If IN is a pseudo register everywhere-equivalent to a constant, and 
  738.      it is not in a hard register, reload straight from the constant,
  739.      since we want to get rid of such pseudo registers.
  740.      Often this is done earlier, but not always in find_reloads_address.  */
  741.   if (in != 0 && GET_CODE (in) == REG)
  742.     {
  743.       register int regno = REGNO (in);
  744.  
  745.       if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0
  746.       && reg_equiv_constant[regno] != 0)
  747.     in = reg_equiv_constant[regno];
  748.     }
  749.  
  750.   /* Likewise for OUT.  Of course, OUT will never be equivalent to
  751.      an actual constant, but it might be equivalent to a memory location
  752.      (in the case of a parameter).  */
  753.   if (out != 0 && GET_CODE (out) == REG)
  754.     {
  755.       register int regno = REGNO (out);
  756.  
  757.       if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0
  758.       && reg_equiv_constant[regno] != 0)
  759.     out = reg_equiv_constant[regno];
  760.     }
  761.  
  762.   /* If we have a read-write operand with an address side-effect,
  763.      change either IN or OUT so the side-effect happens only once.  */
  764.   if (in != 0 && out != 0 && GET_CODE (in) == MEM && rtx_equal_p (in, out))
  765.     {
  766.       if (GET_CODE (XEXP (in, 0)) == POST_INC
  767.       || GET_CODE (XEXP (in, 0)) == POST_DEC)
  768.     in = gen_rtx (MEM, GET_MODE (in), XEXP (XEXP (in, 0), 0));
  769.       if (GET_CODE (XEXP (in, 0)) == PRE_INC
  770.       || GET_CODE (XEXP (in, 0)) == PRE_DEC)
  771.     out = gen_rtx (MEM, GET_MODE (out), XEXP (XEXP (out, 0), 0));
  772.     }
  773.  
  774.   /* If we are reloading a (SUBREG constant ...), really reload just the
  775.      inside expression in its own mode.  Similarly for (SUBREG (PLUS ...)).
  776.      If we have (SUBREG:M1 (MEM:M2 ...) ...) (or an inner REG that is still
  777.      a pseudo and hence will become a MEM) with M1 wider than M2 and the
  778.      register is a pseudo, also reload the inside expression.
  779.      For machines that extend byte loads, do this for any SUBREG of a pseudo
  780.      where both M1 and M2 are a word or smaller unless they are the same
  781.      size.
  782.      Similar issue for (SUBREG:M1 (REG:M2 ...) ...) for a hard register R where
  783.      either M1 is not valid for R or M2 is wider than a word but we only
  784.      need one word to store an M2-sized quantity in R.
  785.      (However, if OUT is nonzero, we need to reload the reg *and*
  786.      the subreg, so do nothing here, and let following statement handle it.)
  787.  
  788.      Note that the case of (SUBREG (CONST_INT...)...) is handled elsewhere;
  789.      we can't handle it here because CONST_INT does not indicate a mode.
  790.  
  791.      Similarly, we must reload the inside expression if we have a
  792.      STRICT_LOW_PART (presumably, in == out in the cas).
  793.  
  794.      Also reload the inner expression if it does not require a secondary
  795.      reload but the SUBREG does.  */
  796.  
  797.   if (in != 0 && GET_CODE (in) == SUBREG
  798.       && (CONSTANT_P (SUBREG_REG (in))
  799.       || GET_CODE (SUBREG_REG (in)) == PLUS
  800.       || strict_low
  801.       || (((GET_CODE (SUBREG_REG (in)) == REG
  802.         && REGNO (SUBREG_REG (in)) >= FIRST_PSEUDO_REGISTER)
  803.            || GET_CODE (SUBREG_REG (in)) == MEM)
  804.           && ((GET_MODE_SIZE (inmode)
  805.            > GET_MODE_SIZE (GET_MODE (SUBREG_REG (in))))
  806. #ifdef LOAD_EXTEND_OP
  807.           || (GET_MODE_SIZE (inmode) <= UNITS_PER_WORD
  808.               && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
  809.               <= UNITS_PER_WORD)
  810.               && (GET_MODE_SIZE (inmode)
  811.               != GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))))
  812. #endif
  813.           ))
  814.       || (GET_CODE (SUBREG_REG (in)) == REG
  815.           && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER
  816.           /* The case where out is nonzero
  817.          is handled differently in the following statement.  */
  818.           && (out == 0 || SUBREG_WORD (in) == 0)
  819.           && ((GET_MODE_SIZE (inmode) <= UNITS_PER_WORD
  820.            && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
  821.                > UNITS_PER_WORD)
  822.            && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
  823.             / UNITS_PER_WORD)
  824.                != HARD_REGNO_NREGS (REGNO (SUBREG_REG (in)),
  825.                         GET_MODE (SUBREG_REG (in)))))
  826.           || ! HARD_REGNO_MODE_OK ((REGNO (SUBREG_REG (in))
  827.                         + SUBREG_WORD (in)),
  828.                        inmode)))
  829. #ifdef SECONDARY_INPUT_RELOAD_CLASS
  830.       || (SECONDARY_INPUT_RELOAD_CLASS (class, inmode, in) != NO_REGS
  831.           && (SECONDARY_INPUT_RELOAD_CLASS (class,
  832.                         GET_MODE (SUBREG_REG (in)),
  833.                         SUBREG_REG (in))
  834.           == NO_REGS))
  835. #endif
  836.       ))
  837.     {
  838.       in_subreg_loc = inloc;
  839.       inloc = &SUBREG_REG (in);
  840.       in = *inloc;
  841. #ifndef LOAD_EXTEND_OP
  842.       if (GET_CODE (in) == MEM)
  843.     /* This is supposed to happen only for paradoxical subregs made by
  844.        combine.c.  (SUBREG (MEM)) isn't supposed to occur other ways.  */
  845.     if (GET_MODE_SIZE (GET_MODE (in)) > GET_MODE_SIZE (inmode))
  846.       abort ();
  847. #endif
  848.       inmode = GET_MODE (in);
  849.     }
  850.  
  851.   /* Similar issue for (SUBREG:M1 (REG:M2 ...) ...) for a hard register R where
  852.      either M1 is not valid for R or M2 is wider than a word but we only
  853.      need one word to store an M2-sized quantity in R.
  854.  
  855.      However, we must reload the inner reg *as well as* the subreg in
  856.      that case.  */
  857.  
  858.   if (in != 0 && GET_CODE (in) == SUBREG
  859.       && GET_CODE (SUBREG_REG (in)) == REG
  860.       && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER
  861.       && (! HARD_REGNO_MODE_OK (REGNO (SUBREG_REG (in)), inmode)
  862.       || (GET_MODE_SIZE (inmode) <= UNITS_PER_WORD
  863.           && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
  864.           > UNITS_PER_WORD)
  865.           && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
  866.            / UNITS_PER_WORD)
  867.           != HARD_REGNO_NREGS (REGNO (SUBREG_REG (in)),
  868.                        GET_MODE (SUBREG_REG (in)))))))
  869.     {
  870.       push_reload (SUBREG_REG (in), NULL_RTX, &SUBREG_REG (in), NULL_PTR,
  871.            GENERAL_REGS, VOIDmode, VOIDmode, 0, 0, opnum, type);
  872.     }
  873.  
  874.  
  875.   /* Similarly for paradoxical and problematical SUBREGs on the output.
  876.      Note that there is no reason we need worry about the previous value
  877.      of SUBREG_REG (out); even if wider than out,
  878.      storing in a subreg is entitled to clobber it all
  879.      (except in the case of STRICT_LOW_PART,
  880.      and in that case the constraint should label it input-output.)  */
  881.   if (out != 0 && GET_CODE (out) == SUBREG
  882.       && (CONSTANT_P (SUBREG_REG (out))
  883.       || strict_low
  884.       || (((GET_CODE (SUBREG_REG (out)) == REG
  885.         && REGNO (SUBREG_REG (out)) >= FIRST_PSEUDO_REGISTER)
  886.            || GET_CODE (SUBREG_REG (out)) == MEM)
  887.           && ((GET_MODE_SIZE (outmode)
  888.            > GET_MODE_SIZE (GET_MODE (SUBREG_REG (out))))
  889. #ifdef LOAD_EXTEND_OP
  890.           || (GET_MODE_SIZE (outmode) <= UNITS_PER_WORD
  891.               && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
  892.               <= UNITS_PER_WORD)
  893.               && (GET_MODE_SIZE (outmode)
  894.               != GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))))
  895. #endif
  896.           ))
  897.       || (GET_CODE (SUBREG_REG (out)) == REG
  898.           && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER
  899.           && ((GET_MODE_SIZE (outmode) <= UNITS_PER_WORD
  900.            && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
  901.                > UNITS_PER_WORD)
  902.            && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
  903.             / UNITS_PER_WORD)
  904.                != HARD_REGNO_NREGS (REGNO (SUBREG_REG (out)),
  905.                         GET_MODE (SUBREG_REG (out)))))
  906.           || ! HARD_REGNO_MODE_OK ((REGNO (SUBREG_REG (out))
  907.                         + SUBREG_WORD (out)),
  908.                        outmode)))
  909. #ifdef SECONDARY_OUTPUT_RELOAD_CLASS
  910.       || (SECONDARY_OUTPUT_RELOAD_CLASS (class, outmode, out) != NO_REGS
  911.           && (SECONDARY_OUTPUT_RELOAD_CLASS (class,
  912.                          GET_MODE (SUBREG_REG (out)),
  913.                          SUBREG_REG (out))
  914.           == NO_REGS))
  915. #endif
  916.       ))
  917.     {
  918.       out_subreg_loc = outloc;
  919.       outloc = &SUBREG_REG (out);
  920.       out = *outloc; 
  921. #ifndef LOAD_EXTEND_OP
  922.      if (GET_CODE (out) == MEM
  923.       && GET_MODE_SIZE (GET_MODE (out)) > GET_MODE_SIZE (outmode))
  924.     abort ();
  925. #endif
  926.       outmode = GET_MODE (out);
  927.     }
  928.  
  929.   /* If IN appears in OUT, we can't share any input-only reload for IN.  */
  930.   if (in != 0 && out != 0 && GET_CODE (out) == MEM
  931.       && (GET_CODE (in) == REG || GET_CODE (in) == MEM)
  932.       && reg_overlap_mentioned_for_reload_p (in, XEXP (out, 0)))
  933.     dont_share = 1;
  934.  
  935.   /* If IN is a SUBREG of a hard register, make a new REG.  This
  936.      simplifies some of the cases below.  */
  937.  
  938.   if (in != 0 && GET_CODE (in) == SUBREG && GET_CODE (SUBREG_REG (in)) == REG
  939.       && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER)
  940.     in = gen_rtx (REG, GET_MODE (in),
  941.           REGNO (SUBREG_REG (in)) + SUBREG_WORD (in));
  942.  
  943.   /* Similarly for OUT.  */
  944.   if (out != 0 && GET_CODE (out) == SUBREG
  945.       && GET_CODE (SUBREG_REG (out)) == REG
  946.       && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER)
  947.     out = gen_rtx (REG, GET_MODE (out),
  948.           REGNO (SUBREG_REG (out)) + SUBREG_WORD (out));
  949.  
  950.   /* Narrow down the class of register wanted if that is
  951.      desirable on this machine for efficiency.  */
  952.   if (in != 0)
  953.     class = PREFERRED_RELOAD_CLASS (in, class);
  954.  
  955.   /* Output reloads may need analogous treatment, different in detail.  */
  956. #ifdef PREFERRED_OUTPUT_RELOAD_CLASS
  957.   if (out != 0)
  958.     class = PREFERRED_OUTPUT_RELOAD_CLASS (out, class);
  959. #endif
  960.  
  961.   /* Make sure we use a class that can handle the actual pseudo
  962.      inside any subreg.  For example, on the 386, QImode regs
  963.      can appear within SImode subregs.  Although GENERAL_REGS
  964.      can handle SImode, QImode needs a smaller class.  */
  965. #ifdef LIMIT_RELOAD_CLASS
  966.   if (in_subreg_loc)
  967.     class = LIMIT_RELOAD_CLASS (inmode, class);
  968.   else if (in != 0 && GET_CODE (in) == SUBREG)
  969.     class = LIMIT_RELOAD_CLASS (GET_MODE (SUBREG_REG (in)), class);
  970.  
  971.   if (out_subreg_loc)
  972.     class = LIMIT_RELOAD_CLASS (outmode, class);
  973.   if (out != 0 && GET_CODE (out) == SUBREG)
  974.     class = LIMIT_RELOAD_CLASS (GET_MODE (SUBREG_REG (out)), class);
  975. #endif
  976.  
  977.   /* Verify that this class is at least possible for the mode that
  978.      is specified.  */
  979.   if (this_insn_is_asm)
  980.     {
  981.       enum machine_mode mode;
  982.       if (GET_MODE_SIZE (inmode) > GET_MODE_SIZE (outmode))
  983.     mode = inmode;
  984.       else
  985.     mode = outmode;
  986.       if (mode == VOIDmode)
  987.     {
  988.       error_for_asm (this_insn, "cannot reload integer constant operand in `asm'");
  989.       mode = word_mode;
  990.       if (in != 0)
  991.         inmode = word_mode;
  992.       if (out != 0)
  993.         outmode = word_mode;
  994.     }
  995.       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  996.     if (HARD_REGNO_MODE_OK (i, mode)
  997.         && TEST_HARD_REG_BIT (reg_class_contents[(int) class], i))
  998.       {
  999.         int nregs = HARD_REGNO_NREGS (i, mode);
  1000.  
  1001.         int j;
  1002.         for (j = 1; j < nregs; j++)
  1003.           if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class], i + j))
  1004.         break;
  1005.         if (j == nregs)
  1006.           break;
  1007.       }
  1008.       if (i == FIRST_PSEUDO_REGISTER)
  1009.     {
  1010.       error_for_asm (this_insn, "impossible register constraint in `asm'");
  1011.       class = ALL_REGS;
  1012.     }
  1013.     }
  1014.  
  1015.   if (class == NO_REGS)
  1016.     abort ();
  1017.  
  1018.   /* We can use an existing reload if the class is right
  1019.      and at least one of IN and OUT is a match
  1020.      and the other is at worst neutral.
  1021.      (A zero compared against anything is neutral.) 
  1022.  
  1023.      If SMALL_REGISTER_CLASSES, don't use existing reloads unless they are
  1024.      for the same thing since that can cause us to need more reload registers
  1025.      than we otherwise would.  */
  1026.  
  1027.   for (i = 0; i < n_reloads; i++)
  1028.     if ((reg_class_subset_p (class, reload_reg_class[i])
  1029.      || reg_class_subset_p (reload_reg_class[i], class))
  1030.     /* If the existing reload has a register, it must fit our class.  */
  1031.     && (reload_reg_rtx[i] == 0
  1032.         || TEST_HARD_REG_BIT (reg_class_contents[(int) class],
  1033.                   true_regnum (reload_reg_rtx[i])))
  1034.     && ((in != 0 && MATCHES (reload_in[i], in) && ! dont_share
  1035.          && (out == 0 || reload_out[i] == 0 || MATCHES (reload_out[i], out)))
  1036.         ||
  1037.         (out != 0 && MATCHES (reload_out[i], out)
  1038.          && (in == 0 || reload_in[i] == 0 || MATCHES (reload_in[i], in))))
  1039.     && (reg_class_size[(int) class] == 1
  1040. #ifdef SMALL_REGISTER_CLASSES
  1041.         || 1
  1042. #endif
  1043.         )
  1044.     && MERGABLE_RELOADS (type, reload_when_needed[i],
  1045.                  opnum, reload_opnum[i]))
  1046.       break;
  1047.  
  1048.   /* Reloading a plain reg for input can match a reload to postincrement
  1049.      that reg, since the postincrement's value is the right value.
  1050.      Likewise, it can match a preincrement reload, since we regard
  1051.      the preincrementation as happening before any ref in this insn
  1052.      to that register.  */
  1053.   if (i == n_reloads)
  1054.     for (i = 0; i < n_reloads; i++)
  1055.       if ((reg_class_subset_p (class, reload_reg_class[i])
  1056.        || reg_class_subset_p (reload_reg_class[i], class))
  1057.       /* If the existing reload has a register, it must fit our class.  */
  1058.       && (reload_reg_rtx[i] == 0
  1059.           || TEST_HARD_REG_BIT (reg_class_contents[(int) class],
  1060.                     true_regnum (reload_reg_rtx[i])))
  1061.       && out == 0 && reload_out[i] == 0 && reload_in[i] != 0
  1062.       && ((GET_CODE (in) == REG
  1063.            && (GET_CODE (reload_in[i]) == POST_INC
  1064.            || GET_CODE (reload_in[i]) == POST_DEC
  1065.            || GET_CODE (reload_in[i]) == PRE_INC
  1066.            || GET_CODE (reload_in[i]) == PRE_DEC)
  1067.            && MATCHES (XEXP (reload_in[i], 0), in))
  1068.           ||
  1069.           (GET_CODE (reload_in[i]) == REG
  1070.            && (GET_CODE (in) == POST_INC
  1071.            || GET_CODE (in) == POST_DEC
  1072.            || GET_CODE (in) == PRE_INC
  1073.            || GET_CODE (in) == PRE_DEC)
  1074.            && MATCHES (XEXP (in, 0), reload_in[i])))
  1075.       && (reg_class_size[(int) class] == 1
  1076. #ifdef SMALL_REGISTER_CLASSES
  1077.           || 1
  1078. #endif
  1079.           )
  1080.       && MERGABLE_RELOADS (type, reload_when_needed[i],
  1081.                    opnum, reload_opnum[i]))
  1082.     {
  1083.       /* Make sure reload_in ultimately has the increment,
  1084.          not the plain register.  */
  1085.       if (GET_CODE (in) == REG)
  1086.         in = reload_in[i];
  1087.       break;
  1088.     }
  1089.  
  1090.   if (i == n_reloads)
  1091.     {
  1092.       /* See if we need a secondary reload register to move between CLASS
  1093.      and IN or CLASS and OUT.  Get the icode and push any required reloads
  1094.      needed for each of them if so.  */
  1095.  
  1096. #ifdef SECONDARY_INPUT_RELOAD_CLASS
  1097.       if (in != 0)
  1098.     secondary_in_reload
  1099.       = push_secondary_reload (1, in, opnum, optional, class, inmode, type,
  1100.                    &secondary_in_icode);
  1101. #endif
  1102.  
  1103. #ifdef SECONDARY_OUTPUT_RELOAD_CLASS
  1104.       if (out != 0 && GET_CODE (out) != SCRATCH)
  1105.     secondary_out_reload
  1106.       = push_secondary_reload (0, out, opnum, optional, class, outmode,
  1107.                    type, &secondary_out_icode);
  1108. #endif
  1109.  
  1110.       /* We found no existing reload suitable for re-use.
  1111.      So add an additional reload.  */
  1112.  
  1113.       i = n_reloads;
  1114.       reload_in[i] = in;
  1115.       reload_out[i] = out;
  1116.       reload_reg_class[i] = class;
  1117.       reload_inmode[i] = inmode;
  1118.       reload_outmode[i] = outmode;
  1119.       reload_reg_rtx[i] = 0;
  1120.       reload_optional[i] = optional;
  1121.       reload_inc[i] = 0;
  1122.       reload_nocombine[i] = 0;
  1123.       reload_in_reg[i] = inloc ? *inloc : 0;
  1124.       reload_opnum[i] = opnum;
  1125.       reload_when_needed[i] = type;
  1126.       reload_secondary_in_reload[i] = secondary_in_reload;
  1127.       reload_secondary_out_reload[i] = secondary_out_reload;
  1128.       reload_secondary_in_icode[i] = secondary_in_icode;
  1129.       reload_secondary_out_icode[i] = secondary_out_icode;
  1130.       reload_secondary_p[i] = 0;
  1131.  
  1132.       n_reloads++;
  1133.  
  1134. #ifdef SECONDARY_MEMORY_NEEDED
  1135.       /* If a memory location is needed for the copy, make one.  */
  1136.       if (in != 0 && GET_CODE (in) == REG
  1137.       && REGNO (in) < FIRST_PSEUDO_REGISTER
  1138.       && SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (REGNO (in)),
  1139.                      class, inmode))
  1140.     get_secondary_mem (in, inmode, opnum, type);
  1141.  
  1142.       if (out != 0 && GET_CODE (out) == REG
  1143.       && REGNO (out) < FIRST_PSEUDO_REGISTER
  1144.       && SECONDARY_MEMORY_NEEDED (class, REGNO_REG_CLASS (REGNO (out)),
  1145.                       outmode))
  1146.     get_secondary_mem (out, outmode, opnum, type);
  1147. #endif
  1148.     }
  1149.   else
  1150.     {
  1151.       /* We are reusing an existing reload,
  1152.      but we may have additional information for it.
  1153.      For example, we may now have both IN and OUT
  1154.      while the old one may have just one of them.  */
  1155.  
  1156.       if (inmode != VOIDmode)
  1157.     reload_inmode[i] = inmode;
  1158.       if (outmode != VOIDmode)
  1159.     reload_outmode[i] = outmode;
  1160.       if (in != 0)
  1161.     reload_in[i] = in;
  1162.       if (out != 0)
  1163.     reload_out[i] = out;
  1164.       if (reg_class_subset_p (class, reload_reg_class[i]))
  1165.     reload_reg_class[i] = class;
  1166.       reload_optional[i] &= optional;
  1167.       if (MERGE_TO_OTHER (type, reload_when_needed[i],
  1168.               opnum, reload_opnum[i]))
  1169.     reload_when_needed[i] = RELOAD_OTHER;
  1170.       reload_opnum[i] = MIN (reload_opnum[i], opnum);
  1171.     }
  1172.  
  1173.   /* If the ostensible rtx being reload differs from the rtx found
  1174.      in the location to substitute, this reload is not safe to combine
  1175.      because we cannot reliably tell whether it appears in the insn.  */
  1176.  
  1177.   if (in != 0 && in != *inloc)
  1178.     reload_nocombine[i] = 1;
  1179.  
  1180. #if 0
  1181.   /* This was replaced by changes in find_reloads_address_1 and the new
  1182.      function inc_for_reload, which go with a new meaning of reload_inc.  */
  1183.  
  1184.   /* If this is an IN/OUT reload in an insn that sets the CC,
  1185.      it must be for an autoincrement.  It doesn't work to store
  1186.      the incremented value after the insn because that would clobber the CC.
  1187.      So we must do the increment of the value reloaded from,
  1188.      increment it, store it back, then decrement again.  */
  1189.   if (out != 0 && sets_cc0_p (PATTERN (this_insn)))
  1190.     {
  1191.       out = 0;
  1192.       reload_out[i] = 0;
  1193.       reload_inc[i] = find_inc_amount (PATTERN (this_insn), in);
  1194.       /* If we did not find a nonzero amount-to-increment-by,
  1195.      that contradicts the belief that IN is being incremented
  1196.      in an address in this insn.  */
  1197.       if (reload_inc[i] == 0)
  1198.     abort ();
  1199.     }
  1200. #endif
  1201.  
  1202.   /* If we will replace IN and OUT with the reload-reg,
  1203.      record where they are located so that substitution need
  1204.      not do a tree walk.  */
  1205.  
  1206.   if (replace_reloads)
  1207.     {
  1208.       if (inloc != 0)
  1209.     {
  1210.       register struct replacement *r = &replacements[n_replacements++];
  1211.       r->what = i;
  1212.       r->subreg_loc = in_subreg_loc;
  1213.       r->where = inloc;
  1214.       r->mode = inmode;
  1215.     }
  1216.       if (outloc != 0 && outloc != inloc)
  1217.     {
  1218.       register struct replacement *r = &replacements[n_replacements++];
  1219.       r->what = i;
  1220.       r->where = outloc;
  1221.       r->subreg_loc = out_subreg_loc;
  1222.       r->mode = outmode;
  1223.     }
  1224.     }
  1225.  
  1226.   /* If this reload is just being introduced and it has both
  1227.      an incoming quantity and an outgoing quantity that are
  1228.      supposed to be made to match, see if either one of the two
  1229.      can serve as the place to reload into.
  1230.  
  1231.      If one of them is acceptable, set reload_reg_rtx[i]
  1232.      to that one.  */
  1233.  
  1234.   if (in != 0 && out != 0 && in != out && reload_reg_rtx[i] == 0)
  1235.     {
  1236.       reload_reg_rtx[i] = find_dummy_reload (in, out, inloc, outloc,
  1237.                          inmode, outmode,
  1238.                          reload_reg_class[i], i);
  1239.  
  1240.       /* If the outgoing register already contains the same value
  1241.      as the incoming one, we can dispense with loading it.
  1242.      The easiest way to tell the caller that is to give a phony
  1243.      value for the incoming operand (same as outgoing one).  */
  1244.       if (reload_reg_rtx[i] == out
  1245.       && (GET_CODE (in) == REG || CONSTANT_P (in))
  1246.       && 0 != find_equiv_reg (in, this_insn, 0, REGNO (out),
  1247.                   static_reload_reg_p, i, inmode))
  1248.     reload_in[i] = out;
  1249.     }
  1250.  
  1251.   /* If this is an input reload and the operand contains a register that
  1252.      dies in this insn and is used nowhere else, see if it is the right class
  1253.      to be used for this reload.  Use it if so.  (This occurs most commonly
  1254.      in the case of paradoxical SUBREGs and in-out reloads).  We cannot do
  1255.      this if it is also an output reload that mentions the register unless
  1256.      the output is a SUBREG that clobbers an entire register.
  1257.  
  1258.      Note that the operand might be one of the spill regs, if it is a
  1259.      pseudo reg and we are in a block where spilling has not taken place.
  1260.      But if there is no spilling in this block, that is OK.
  1261.      An explicitly used hard reg cannot be a spill reg.  */
  1262.  
  1263.   if (reload_reg_rtx[i] == 0 && in != 0)
  1264.     {
  1265.       rtx note;
  1266.       int regno;
  1267.  
  1268.       for (note = REG_NOTES (this_insn); note; note = XEXP (note, 1))
  1269.     if (REG_NOTE_KIND (note) == REG_DEAD
  1270.         && GET_CODE (XEXP (note, 0)) == REG
  1271.         && (regno = REGNO (XEXP (note, 0))) < FIRST_PSEUDO_REGISTER
  1272.         && reg_mentioned_p (XEXP (note, 0), in)
  1273.         && ! refers_to_regno_for_reload_p (regno,
  1274.                            (regno
  1275.                         + HARD_REGNO_NREGS (regno,
  1276.                                     inmode)),
  1277.                            PATTERN (this_insn), inloc)
  1278.         /* If this is also an output reload, IN cannot be used as
  1279.            the reload register if it is set in this insn unless IN
  1280.            is also OUT.  */
  1281.         && (out == 0 || in == out
  1282.         || ! hard_reg_set_here_p (regno,
  1283.                       (regno
  1284.                        + HARD_REGNO_NREGS (regno,
  1285.                                    inmode)),
  1286.                       PATTERN (this_insn)))
  1287.         /* ??? Why is this code so different from the previous?
  1288.            Is there any simple coherent way to describe the two together?
  1289.            What's going on here.  */
  1290.         && (in != out
  1291.         || (GET_CODE (in) == SUBREG
  1292.             && (((GET_MODE_SIZE (GET_MODE (in)) + (UNITS_PER_WORD - 1))
  1293.              / UNITS_PER_WORD)
  1294.             == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
  1295.                  + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD))))
  1296.         /* Make sure the operand fits in the reg that dies.  */
  1297.         && GET_MODE_SIZE (inmode) <= GET_MODE_SIZE (GET_MODE (XEXP (note, 0)))
  1298.         && HARD_REGNO_MODE_OK (regno, inmode)
  1299.         && GET_MODE_SIZE (outmode) <= GET_MODE_SIZE (GET_MODE (XEXP (note, 0)))
  1300.         && HARD_REGNO_MODE_OK (regno, outmode)
  1301.         && TEST_HARD_REG_BIT (reg_class_contents[(int) class], regno)
  1302.         && !fixed_regs[regno])
  1303.       {
  1304.         reload_reg_rtx[i] = gen_rtx (REG, inmode, regno);
  1305.         break;
  1306.       }
  1307.     }
  1308.  
  1309.   if (out)
  1310.     output_reloadnum = i;
  1311.  
  1312.   return i;
  1313. }
  1314.  
  1315. /* Record an additional place we must replace a value
  1316.    for which we have already recorded a reload.
  1317.    RELOADNUM is the value returned by push_reload
  1318.    when the reload was recorded.
  1319.    This is used in insn patterns that use match_dup.  */
  1320.  
  1321. static void
  1322. push_replacement (loc, reloadnum, mode)
  1323.      rtx *loc;
  1324.      int reloadnum;
  1325.      enum machine_mode mode;
  1326. {
  1327.   if (replace_reloads)
  1328.     {
  1329.       register struct replacement *r = &replacements[n_replacements++];
  1330.       r->what = reloadnum;
  1331.       r->where = loc;
  1332.       r->subreg_loc = 0;
  1333.       r->mode = mode;
  1334.     }
  1335. }
  1336.  
  1337. /* Transfer all replacements that used to be in reload FROM to be in
  1338.    reload TO.  */
  1339.  
  1340. void
  1341. transfer_replacements (to, from)
  1342.      int to, from;
  1343. {
  1344.   int i;
  1345.  
  1346.   for (i = 0; i < n_replacements; i++)
  1347.     if (replacements[i].what == from)
  1348.       replacements[i].what = to;
  1349. }
  1350.  
  1351. /* If there is only one output reload, and it is not for an earlyclobber
  1352.    operand, try to combine it with a (logically unrelated) input reload
  1353.    to reduce the number of reload registers needed.
  1354.  
  1355.    This is safe if the input reload does not appear in
  1356.    the value being output-reloaded, because this implies
  1357.    it is not needed any more once the original insn completes.
  1358.  
  1359.    If that doesn't work, see we can use any of the registers that
  1360.    die in this insn as a reload register.  We can if it is of the right
  1361.    class and does not appear in the value being output-reloaded.  */
  1362.  
  1363. static void
  1364. combine_reloads ()
  1365. {
  1366.   int i;
  1367.   int output_reload = -1;
  1368.   rtx note;
  1369.  
  1370.   /* Find the output reload; return unless there is exactly one
  1371.      and that one is mandatory.  */
  1372.  
  1373.   for (i = 0; i < n_reloads; i++)
  1374.     if (reload_out[i] != 0)
  1375.       {
  1376.     if (output_reload >= 0)
  1377.       return;
  1378.     output_reload = i;
  1379.       }
  1380.  
  1381.   if (output_reload < 0 || reload_optional[output_reload])
  1382.     return;
  1383.  
  1384.   /* An input-output reload isn't combinable.  */
  1385.  
  1386.   if (reload_in[output_reload] != 0)
  1387.     return;
  1388.  
  1389.   /* If this reload is for an earlyclobber operand, we can't do anything.  */
  1390.   if (earlyclobber_operand_p (reload_out[output_reload]))
  1391.     return;
  1392.  
  1393.   /* Check each input reload; can we combine it?  */
  1394.  
  1395.   for (i = 0; i < n_reloads; i++)
  1396.     if (reload_in[i] && ! reload_optional[i] && ! reload_nocombine[i]
  1397.     /* Life span of this reload must not extend past main insn.  */
  1398.     && reload_when_needed[i] != RELOAD_FOR_OUTPUT_ADDRESS
  1399.     && reload_when_needed[i] != RELOAD_OTHER
  1400.     && (CLASS_MAX_NREGS (reload_reg_class[i], reload_inmode[i])
  1401.         == CLASS_MAX_NREGS (reload_reg_class[output_reload],
  1402.                 reload_outmode[output_reload]))
  1403.     && reload_inc[i] == 0
  1404.     && reload_reg_rtx[i] == 0
  1405. #ifdef SECONDARY_MEMORY_NEEDED
  1406.     /* Don't combine two reloads with different secondary
  1407.        memory locations.  */
  1408.     && (secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[i]] == 0
  1409.         || secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]] == 0
  1410.         || rtx_equal_p (secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[i]],
  1411.                 secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]]))
  1412. #endif
  1413. #ifdef SMALL_REGISTER_CLASSES
  1414.     && reload_reg_class[i] == reload_reg_class[output_reload]
  1415. #else
  1416.     && (reg_class_subset_p (reload_reg_class[i],
  1417.                 reload_reg_class[output_reload])
  1418.         || reg_class_subset_p (reload_reg_class[output_reload],
  1419.                    reload_reg_class[i]))
  1420. #endif
  1421.     && (MATCHES (reload_in[i], reload_out[output_reload])
  1422.         /* Args reversed because the first arg seems to be
  1423.            the one that we imagine being modified
  1424.            while the second is the one that might be affected.  */
  1425.         || (! reg_overlap_mentioned_for_reload_p (reload_out[output_reload],
  1426.                               reload_in[i])
  1427.         /* However, if the input is a register that appears inside
  1428.            the output, then we also can't share.
  1429.            Imagine (set (mem (reg 69)) (plus (reg 69) ...)).
  1430.            If the same reload reg is used for both reg 69 and the
  1431.            result to be stored in memory, then that result
  1432.            will clobber the address of the memory ref.  */
  1433.         && ! (GET_CODE (reload_in[i]) == REG
  1434.               && reg_overlap_mentioned_for_reload_p (reload_in[i],
  1435.                                  reload_out[output_reload]))))
  1436.     && (reg_class_size[(int) reload_reg_class[i]]
  1437. #ifdef SMALL_REGISTER_CLASSES
  1438.          || 1
  1439. #endif
  1440.         )
  1441.     /* We will allow making things slightly worse by combining an
  1442.        input and an output, but no worse than that.  */
  1443.     && (reload_when_needed[i] == RELOAD_FOR_INPUT
  1444.         || reload_when_needed[i] == RELOAD_FOR_OUTPUT))
  1445.       {
  1446.     int j;
  1447.  
  1448.     /* We have found a reload to combine with!  */
  1449.     reload_out[i] = reload_out[output_reload];
  1450.     reload_outmode[i] = reload_outmode[output_reload];
  1451.     /* Mark the old output reload as inoperative.  */
  1452.     reload_out[output_reload] = 0;
  1453.     /* The combined reload is needed for the entire insn.  */
  1454.     reload_when_needed[i] = RELOAD_OTHER;
  1455.     /* If the output reload had a secondary reload, copy it. */
  1456.     if (reload_secondary_out_reload[output_reload] != -1)
  1457.       {
  1458.         reload_secondary_out_reload[i]
  1459.           = reload_secondary_out_reload[output_reload];
  1460.         reload_secondary_out_icode[i]
  1461.           = reload_secondary_out_icode[output_reload];
  1462.       }
  1463.  
  1464. #ifdef SECONDARY_MEMORY_NEEDED
  1465.     /* Copy any secondary MEM.  */
  1466.     if (secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]] != 0)
  1467.       secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[i]]
  1468.         = secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]];
  1469. #endif
  1470.     /* If required, minimize the register class. */
  1471.     if (reg_class_subset_p (reload_reg_class[output_reload],
  1472.                 reload_reg_class[i]))
  1473.       reload_reg_class[i] = reload_reg_class[output_reload];
  1474.  
  1475.     /* Transfer all replacements from the old reload to the combined.  */
  1476.     for (j = 0; j < n_replacements; j++)
  1477.       if (replacements[j].what == output_reload)
  1478.         replacements[j].what = i;
  1479.  
  1480.     return;
  1481.       }
  1482.  
  1483.   /* If this insn has only one operand that is modified or written (assumed
  1484.      to be the first),  it must be the one corresponding to this reload.  It
  1485.      is safe to use anything that dies in this insn for that output provided
  1486.      that it does not occur in the output (we already know it isn't an
  1487.      earlyclobber.  If this is an asm insn, give up.  */
  1488.  
  1489.   if (INSN_CODE (this_insn) == -1)
  1490.     return;
  1491.  
  1492.   for (i = 1; i < insn_n_operands[INSN_CODE (this_insn)]; i++)
  1493.     if (insn_operand_constraint[INSN_CODE (this_insn)][i][0] == '='
  1494.     || insn_operand_constraint[INSN_CODE (this_insn)][i][0] == '+')
  1495.       return;
  1496.  
  1497.   /* See if some hard register that dies in this insn and is not used in
  1498.      the output is the right class.  Only works if the register we pick
  1499.      up can fully hold our output reload.  */
  1500.   for (note = REG_NOTES (this_insn); note; note = XEXP (note, 1))
  1501.     if (REG_NOTE_KIND (note) == REG_DEAD
  1502.     && GET_CODE (XEXP (note, 0)) == REG
  1503.     && ! reg_overlap_mentioned_for_reload_p (XEXP (note, 0),
  1504.                          reload_out[output_reload])
  1505.     && REGNO (XEXP (note, 0)) < FIRST_PSEUDO_REGISTER
  1506.     && HARD_REGNO_MODE_OK (REGNO (XEXP (note, 0)), reload_outmode[output_reload])
  1507.     && TEST_HARD_REG_BIT (reg_class_contents[(int) reload_reg_class[output_reload]],
  1508.                   REGNO (XEXP (note, 0)))
  1509.     && (HARD_REGNO_NREGS (REGNO (XEXP (note, 0)), reload_outmode[output_reload])
  1510.         <= HARD_REGNO_NREGS (REGNO (XEXP (note, 0)), GET_MODE (XEXP (note, 0))))
  1511.     && ! fixed_regs[REGNO (XEXP (note, 0))])
  1512.       {
  1513.     reload_reg_rtx[output_reload] = gen_rtx (REG,
  1514.                          reload_outmode[output_reload],
  1515.                          REGNO (XEXP (note, 0)));
  1516.     return;
  1517.       }
  1518. }
  1519.  
  1520. /* Try to find a reload register for an in-out reload (expressions IN and OUT).
  1521.    See if one of IN and OUT is a register that may be used;
  1522.    this is desirable since a spill-register won't be needed.
  1523.    If so, return the register rtx that proves acceptable.
  1524.  
  1525.    INLOC and OUTLOC are locations where IN and OUT appear in the insn.
  1526.    CLASS is the register class required for the reload.
  1527.  
  1528.    If FOR_REAL is >= 0, it is the number of the reload,
  1529.    and in some cases when it can be discovered that OUT doesn't need
  1530.    to be computed, clear out reload_out[FOR_REAL].
  1531.  
  1532.    If FOR_REAL is -1, this should not be done, because this call
  1533.    is just to see if a register can be found, not to find and install it.  */
  1534.  
  1535. static rtx
  1536. find_dummy_reload (real_in, real_out, inloc, outloc,
  1537.            inmode, outmode, class, for_real)
  1538.      rtx real_in, real_out;
  1539.      rtx *inloc, *outloc;
  1540.      enum machine_mode inmode, outmode;
  1541.      enum reg_class class;
  1542.      int for_real;
  1543. {
  1544.   rtx in = real_in;
  1545.   rtx out = real_out;
  1546.   int in_offset = 0;
  1547.   int out_offset = 0;
  1548.   rtx value = 0;
  1549.  
  1550.   /* If operands exceed a word, we can't use either of them
  1551.      unless they have the same size.  */
  1552.   if (GET_MODE_SIZE (outmode) != GET_MODE_SIZE (inmode)
  1553.       && (GET_MODE_SIZE (outmode) > UNITS_PER_WORD
  1554.       || GET_MODE_SIZE (inmode) > UNITS_PER_WORD))
  1555.     return 0;
  1556.  
  1557.   /* Find the inside of any subregs.  */
  1558.   while (GET_CODE (out) == SUBREG)
  1559.     {
  1560.       out_offset = SUBREG_WORD (out);
  1561.       out = SUBREG_REG (out);
  1562.     }
  1563.   while (GET_CODE (in) == SUBREG)
  1564.     {
  1565.       in_offset = SUBREG_WORD (in);
  1566.       in = SUBREG_REG (in);
  1567.     }
  1568.  
  1569.   /* Narrow down the reg class, the same way push_reload will;
  1570.      otherwise we might find a dummy now, but push_reload won't.  */
  1571.   class = PREFERRED_RELOAD_CLASS (in, class);
  1572.  
  1573.   /* See if OUT will do.  */
  1574.   if (GET_CODE (out) == REG
  1575.       && REGNO (out) < FIRST_PSEUDO_REGISTER)
  1576.     {
  1577.       register int regno = REGNO (out) + out_offset;
  1578.       int nwords = HARD_REGNO_NREGS (regno, outmode);
  1579.       rtx saved_rtx;
  1580.  
  1581.       /* When we consider whether the insn uses OUT,
  1582.      ignore references within IN.  They don't prevent us
  1583.      from copying IN into OUT, because those refs would
  1584.      move into the insn that reloads IN.
  1585.  
  1586.      However, we only ignore IN in its role as this reload.
  1587.      If the insn uses IN elsewhere and it contains OUT,
  1588.      that counts.  We can't be sure it's the "same" operand
  1589.      so it might not go through this reload.  */
  1590.       saved_rtx = *inloc;
  1591.       *inloc = const0_rtx;
  1592.  
  1593.       if (regno < FIRST_PSEUDO_REGISTER
  1594.       /* A fixed reg that can overlap other regs better not be used
  1595.          for reloading in any way.  */
  1596. #ifdef OVERLAPPING_REGNO_P
  1597.       && ! (fixed_regs[regno] && OVERLAPPING_REGNO_P (regno))
  1598. #endif
  1599.       && ! refers_to_regno_for_reload_p (regno, regno + nwords,
  1600.                          PATTERN (this_insn), outloc))
  1601.     {
  1602.       int i;
  1603.       for (i = 0; i < nwords; i++)
  1604.         if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
  1605.                      regno + i))
  1606.           break;
  1607.  
  1608.       if (i == nwords)
  1609.         {
  1610.           if (GET_CODE (real_out) == REG)
  1611.         value = real_out;
  1612.           else
  1613.         value = gen_rtx (REG, outmode, regno);
  1614.         }
  1615.     }
  1616.  
  1617.       *inloc = saved_rtx;
  1618.     }
  1619.  
  1620.   /* Consider using IN if OUT was not acceptable
  1621.      or if OUT dies in this insn (like the quotient in a divmod insn).
  1622.      We can't use IN unless it is dies in this insn,
  1623.      which means we must know accurately which hard regs are live.
  1624.      Also, the result can't go in IN if IN is used within OUT.  */
  1625.   if (hard_regs_live_known
  1626.       && GET_CODE (in) == REG
  1627.       && REGNO (in) < FIRST_PSEUDO_REGISTER
  1628.       && (value == 0
  1629.       || find_reg_note (this_insn, REG_UNUSED, real_out))
  1630.       && find_reg_note (this_insn, REG_DEAD, real_in)
  1631.       && !fixed_regs[REGNO (in)]
  1632.       && HARD_REGNO_MODE_OK (REGNO (in),
  1633.                  /* The only case where out and real_out might
  1634.                 have different modes is where real_out
  1635.                 is a subreg, and in that case, out
  1636.                 has a real mode.  */
  1637.                  (GET_MODE (out) != VOIDmode
  1638.                   ? GET_MODE (out) : outmode)))
  1639.     {
  1640.       register int regno = REGNO (in) + in_offset;
  1641.       int nwords = HARD_REGNO_NREGS (regno, inmode);
  1642.  
  1643.       if (! refers_to_regno_for_reload_p (regno, regno + nwords, out, NULL_PTR)
  1644.       && ! hard_reg_set_here_p (regno, regno + nwords,
  1645.                     PATTERN (this_insn)))
  1646.     {
  1647.       int i;
  1648.       for (i = 0; i < nwords; i++)
  1649.         if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
  1650.                      regno + i))
  1651.           break;
  1652.  
  1653.       if (i == nwords)
  1654.         {
  1655.           /* If we were going to use OUT as the reload reg
  1656.          and changed our mind, it means OUT is a dummy that
  1657.          dies here.  So don't bother copying value to it.  */
  1658.           if (for_real >= 0 && value == real_out)
  1659.         reload_out[for_real] = 0;
  1660.           if (GET_CODE (real_in) == REG)
  1661.         value = real_in;
  1662.           else
  1663.         value = gen_rtx (REG, inmode, regno);
  1664.         }
  1665.     }
  1666.     }
  1667.  
  1668.   return value;
  1669. }
  1670.  
  1671. /* This page contains subroutines used mainly for determining
  1672.    whether the IN or an OUT of a reload can serve as the
  1673.    reload register.  */
  1674.  
  1675. /* Return 1 if X is an operand of an insn that is being earlyclobbered.  */
  1676.  
  1677. static int
  1678. earlyclobber_operand_p (x)
  1679.      rtx x;
  1680. {
  1681.   int i;
  1682.  
  1683.   for (i = 0; i < n_earlyclobbers; i++)
  1684.     if (reload_earlyclobbers[i] == x)
  1685.       return 1;
  1686.  
  1687.   return 0;
  1688. }
  1689.  
  1690. /* Return 1 if expression X alters a hard reg in the range
  1691.    from BEG_REGNO (inclusive) to END_REGNO (exclusive),
  1692.    either explicitly or in the guise of a pseudo-reg allocated to REGNO.
  1693.    X should be the body of an instruction.  */
  1694.  
  1695. static int
  1696. hard_reg_set_here_p (beg_regno, end_regno, x)
  1697.      register int beg_regno, end_regno;
  1698.      rtx x;
  1699. {
  1700.   if (GET_CODE (x) == SET || GET_CODE (x) == CLOBBER)
  1701.     {
  1702.       register rtx op0 = SET_DEST (x);
  1703.       while (GET_CODE (op0) == SUBREG)
  1704.     op0 = SUBREG_REG (op0);
  1705.       if (GET_CODE (op0) == REG)
  1706.     {
  1707.       register int r = REGNO (op0);
  1708.       /* See if this reg overlaps range under consideration.  */
  1709.       if (r < end_regno
  1710.           && r + HARD_REGNO_NREGS (r, GET_MODE (op0)) > beg_regno)
  1711.         return 1;
  1712.     }
  1713.     }
  1714.   else if (GET_CODE (x) == PARALLEL)
  1715.     {
  1716.       register int i = XVECLEN (x, 0) - 1;
  1717.       for (; i >= 0; i--)
  1718.     if (hard_reg_set_here_p (beg_regno, end_regno, XVECEXP (x, 0, i)))
  1719.       return 1;
  1720.     }
  1721.  
  1722.   return 0;
  1723. }
  1724.  
  1725. /* Return 1 if ADDR is a valid memory address for mode MODE,
  1726.    and check that each pseudo reg has the proper kind of
  1727.    hard reg.  */
  1728.  
  1729. int
  1730. strict_memory_address_p (mode, addr)
  1731.      enum machine_mode mode;
  1732.      register rtx addr;
  1733. {
  1734.   GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
  1735.   return 0;
  1736.  
  1737.  win:
  1738.   return 1;
  1739. }
  1740.  
  1741. /* Like rtx_equal_p except that it allows a REG and a SUBREG to match
  1742.    if they are the same hard reg, and has special hacks for
  1743.    autoincrement and autodecrement.
  1744.    This is specifically intended for find_reloads to use
  1745.    in determining whether two operands match.
  1746.    X is the operand whose number is the lower of the two.
  1747.  
  1748.    The value is 2 if Y contains a pre-increment that matches
  1749.    a non-incrementing address in X.  */
  1750.  
  1751. /* ??? To be completely correct, we should arrange to pass
  1752.    for X the output operand and for Y the input operand.
  1753.    For now, we assume that the output operand has the lower number
  1754.    because that is natural in (SET output (... input ...)).  */
  1755.  
  1756. int
  1757. operands_match_p (x, y)
  1758.      register rtx x, y;
  1759. {
  1760.   register int i;
  1761.   register RTX_CODE code = GET_CODE (x);
  1762.   register char *fmt;
  1763.   int success_2;
  1764.       
  1765.   if (x == y)
  1766.     return 1;
  1767.   if ((code == REG || (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG))
  1768.       && (GET_CODE (y) == REG || (GET_CODE (y) == SUBREG
  1769.                   && GET_CODE (SUBREG_REG (y)) == REG)))
  1770.     {
  1771.       register int j;
  1772.  
  1773.       if (code == SUBREG)
  1774.     {
  1775.       i = REGNO (SUBREG_REG (x));
  1776.       if (i >= FIRST_PSEUDO_REGISTER)
  1777.         goto slow;
  1778.       i += SUBREG_WORD (x);
  1779.     }
  1780.       else
  1781.     i = REGNO (x);
  1782.  
  1783.       if (GET_CODE (y) == SUBREG)
  1784.     {
  1785.       j = REGNO (SUBREG_REG (y));
  1786.       if (j >= FIRST_PSEUDO_REGISTER)
  1787.         goto slow;
  1788.       j += SUBREG_WORD (y);
  1789.     }
  1790.       else
  1791.     j = REGNO (y);
  1792.  
  1793.       /* On a WORDS_BIG_ENDIAN machine, point to the last register of a
  1794.      multiple hard register group, so that for example (reg:DI 0) and
  1795.      (reg:SI 1) will be considered the same register.  */
  1796.       if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD
  1797.       && i < FIRST_PSEUDO_REGISTER)
  1798.     i += (GET_MODE_SIZE (GET_MODE (x)) / UNITS_PER_WORD) - 1;
  1799.       if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (y)) > UNITS_PER_WORD
  1800.       && j < FIRST_PSEUDO_REGISTER)
  1801.     j += (GET_MODE_SIZE (GET_MODE (y)) / UNITS_PER_WORD) - 1;
  1802.  
  1803.       return i == j;
  1804.     }
  1805.   /* If two operands must match, because they are really a single
  1806.      operand of an assembler insn, then two postincrements are invalid
  1807.      because the assembler insn would increment only once.
  1808.      On the other hand, an postincrement matches ordinary indexing
  1809.      if the postincrement is the output operand.  */
  1810.   if (code == POST_DEC || code == POST_INC)
  1811.     return operands_match_p (XEXP (x, 0), y);
  1812.   /* Two preincrements are invalid
  1813.      because the assembler insn would increment only once.
  1814.      On the other hand, an preincrement matches ordinary indexing
  1815.      if the preincrement is the input operand.
  1816.      In this case, return 2, since some callers need to do special
  1817.      things when this happens.  */
  1818.   if (GET_CODE (y) == PRE_DEC || GET_CODE (y) == PRE_INC)
  1819.     return operands_match_p (x, XEXP (y, 0)) ? 2 : 0;
  1820.  
  1821.  slow:
  1822.  
  1823.   /* Now we have disposed of all the cases 
  1824.      in which different rtx codes can match.  */
  1825.   if (code != GET_CODE (y))
  1826.     return 0;
  1827.   if (code == LABEL_REF)
  1828.     return XEXP (x, 0) == XEXP (y, 0);
  1829.   if (code == SYMBOL_REF)
  1830.     return XSTR (x, 0) == XSTR (y, 0);
  1831.  
  1832.   /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.  */
  1833.  
  1834.   if (GET_MODE (x) != GET_MODE (y))
  1835.     return 0;
  1836.  
  1837.   /* Compare the elements.  If any pair of corresponding elements
  1838.      fail to match, return 0 for the whole things.  */
  1839.  
  1840.   success_2 = 0;
  1841.   fmt = GET_RTX_FORMAT (code);
  1842.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  1843.     {
  1844.       int val;
  1845.       switch (fmt[i])
  1846.     {
  1847.     case 'w':
  1848.       if (XWINT (x, i) != XWINT (y, i))
  1849.         return 0;
  1850.       break;
  1851.  
  1852.     case 'i':
  1853.       if (XINT (x, i) != XINT (y, i))
  1854.         return 0;
  1855.       break;
  1856.  
  1857.     case 'e':
  1858.       val = operands_match_p (XEXP (x, i), XEXP (y, i));
  1859.       if (val == 0)
  1860.         return 0;
  1861.       /* If any subexpression returns 2,
  1862.          we should return 2 if we are successful.  */
  1863.       if (val == 2)
  1864.         success_2 = 1;
  1865.       break;
  1866.  
  1867.     case '0':
  1868.       break;
  1869.  
  1870.       /* It is believed that rtx's at this level will never
  1871.          contain anything but integers and other rtx's,
  1872.          except for within LABEL_REFs and SYMBOL_REFs.  */
  1873.     default:
  1874.       abort ();
  1875.     }
  1876.     }
  1877.   return 1 + success_2;
  1878. }
  1879.  
  1880. /* Return the number of times character C occurs in string S.  */
  1881.  
  1882. int
  1883. n_occurrences (c, s)
  1884.      char c;
  1885.      char *s;
  1886. {
  1887.   int n = 0;
  1888.   while (*s)
  1889.     n += (*s++ == c);
  1890.   return n;
  1891. }
  1892.  
  1893. /* Describe the range of registers or memory referenced by X.
  1894.    If X is a register, set REG_FLAG and put the first register 
  1895.    number into START and the last plus one into END.
  1896.    If X is a memory reference, put a base address into BASE 
  1897.    and a range of integer offsets into START and END.
  1898.    If X is pushing on the stack, we can assume it causes no trouble, 
  1899.    so we set the SAFE field.  */
  1900.  
  1901. static struct decomposition
  1902. decompose (x)
  1903.      rtx x;
  1904. {
  1905.   struct decomposition val;
  1906.   int all_const = 0;
  1907.  
  1908.   val.reg_flag = 0;
  1909.   val.safe = 0;
  1910.   if (GET_CODE (x) == MEM)
  1911.     {
  1912.       rtx base, offset = 0;
  1913.       rtx addr = XEXP (x, 0);
  1914.  
  1915.       if (GET_CODE (addr) == PRE_DEC || GET_CODE (addr) == PRE_INC
  1916.       || GET_CODE (addr) == POST_DEC || GET_CODE (addr) == POST_INC)
  1917.     {
  1918.       val.base = XEXP (addr, 0);
  1919.       val.start = - GET_MODE_SIZE (GET_MODE (x));
  1920.       val.end = GET_MODE_SIZE (GET_MODE (x));
  1921.       val.safe = REGNO (val.base) == STACK_POINTER_REGNUM;
  1922.       return val;
  1923.     }
  1924.  
  1925.       if (GET_CODE (addr) == CONST)
  1926.     {
  1927.       addr = XEXP (addr, 0);
  1928.       all_const = 1;
  1929.     }
  1930.       if (GET_CODE (addr) == PLUS)
  1931.     {
  1932.       if (CONSTANT_P (XEXP (addr, 0)))
  1933.         {
  1934.           base = XEXP (addr, 1);
  1935.           offset = XEXP (addr, 0);
  1936.         }
  1937.       else if (CONSTANT_P (XEXP (addr, 1)))
  1938.         {
  1939.           base = XEXP (addr, 0);
  1940.           offset = XEXP (addr, 1);
  1941.         }
  1942.     }
  1943.  
  1944.       if (offset == 0)
  1945.     {
  1946.       base = addr;
  1947.       offset = const0_rtx;
  1948.     } 
  1949.       if (GET_CODE (offset) == CONST)
  1950.     offset = XEXP (offset, 0);
  1951.       if (GET_CODE (offset) == PLUS)
  1952.     {
  1953.       if (GET_CODE (XEXP (offset, 0)) == CONST_INT)
  1954.         {
  1955.           base = gen_rtx (PLUS, GET_MODE (base), base, XEXP (offset, 1));
  1956.           offset = XEXP (offset, 0);
  1957.         }
  1958.       else if (GET_CODE (XEXP (offset, 1)) == CONST_INT)
  1959.         {
  1960.           base = gen_rtx (PLUS, GET_MODE (base), base, XEXP (offset, 0));
  1961.           offset = XEXP (offset, 1);
  1962.         }
  1963.       else
  1964.         {
  1965.           base = gen_rtx (PLUS, GET_MODE (base), base, offset);
  1966.           offset = const0_rtx;
  1967.         }
  1968.     }
  1969.       else if (GET_CODE (offset) != CONST_INT)
  1970.     {
  1971.       base = gen_rtx (PLUS, GET_MODE (base), base, offset);
  1972.       offset = const0_rtx;
  1973.     }
  1974.  
  1975.       if (all_const && GET_CODE (base) == PLUS)
  1976.     base = gen_rtx (CONST, GET_MODE (base), base);
  1977.  
  1978.       if (GET_CODE (offset) != CONST_INT)
  1979.     abort ();
  1980.  
  1981.       val.start = INTVAL (offset);
  1982.       val.end = val.start + GET_MODE_SIZE (GET_MODE (x));
  1983.       val.base = base;
  1984.       return val;
  1985.     }
  1986.   else if (GET_CODE (x) == REG)
  1987.     {
  1988.       val.reg_flag = 1;
  1989.       val.start = true_regnum (x); 
  1990.       if (val.start < 0)
  1991.     {
  1992.       /* A pseudo with no hard reg.  */
  1993.       val.start = REGNO (x);
  1994.       val.end = val.start + 1;
  1995.     }
  1996.       else
  1997.     /* A hard reg.  */
  1998.     val.end = val.start + HARD_REGNO_NREGS (val.start, GET_MODE (x));
  1999.     }
  2000.   else if (GET_CODE (x) == SUBREG)
  2001.     {
  2002.       if (GET_CODE (SUBREG_REG (x)) != REG)
  2003.     /* This could be more precise, but it's good enough.  */
  2004.     return decompose (SUBREG_REG (x));
  2005.       val.reg_flag = 1;
  2006.       val.start = true_regnum (x); 
  2007.       if (val.start < 0)
  2008.     return decompose (SUBREG_REG (x));
  2009.       else
  2010.     /* A hard reg.  */
  2011.     val.end = val.start + HARD_REGNO_NREGS (val.start, GET_MODE (x));
  2012.     }
  2013.   else if (CONSTANT_P (x)
  2014.        /* This hasn't been assigned yet, so it can't conflict yet.  */
  2015.        || GET_CODE (x) == SCRATCH)
  2016.     val.safe = 1;
  2017.   else
  2018.     abort ();
  2019.   return val;
  2020. }
  2021.  
  2022. /* Return 1 if altering Y will not modify the value of X.
  2023.    Y is also described by YDATA, which should be decompose (Y).  */
  2024.  
  2025. static int
  2026. immune_p (x, y, ydata)
  2027.      rtx x, y;
  2028.      struct decomposition ydata;
  2029. {
  2030.   struct decomposition xdata;
  2031.  
  2032.   if (ydata.reg_flag)
  2033.     return !refers_to_regno_for_reload_p (ydata.start, ydata.end, x, NULL_PTR);
  2034.   if (ydata.safe)
  2035.     return 1;
  2036.  
  2037.   if (GET_CODE (y) != MEM)
  2038.     abort ();
  2039.   /* If Y is memory and X is not, Y can't affect X.  */
  2040.   if (GET_CODE (x) != MEM)
  2041.     return 1;
  2042.  
  2043.   xdata =  decompose (x);
  2044.  
  2045.   if (! rtx_equal_p (xdata.base, ydata.base))
  2046.     {
  2047.       /* If bases are distinct symbolic constants, there is no overlap.  */
  2048.       if (CONSTANT_P (xdata.base) && CONSTANT_P (ydata.base))
  2049.     return 1;
  2050.       /* Constants and stack slots never overlap.  */
  2051.       if (CONSTANT_P (xdata.base)
  2052.       && (ydata.base == frame_pointer_rtx
  2053.           || ydata.base == hard_frame_pointer_rtx
  2054.           || ydata.base == stack_pointer_rtx))
  2055.     return 1;
  2056.       if (CONSTANT_P (ydata.base)
  2057.       && (xdata.base == frame_pointer_rtx
  2058.           || xdata.base == hard_frame_pointer_rtx
  2059.           || xdata.base == stack_pointer_rtx))
  2060.     return 1;
  2061.       /* If either base is variable, we don't know anything.  */
  2062.       return 0;
  2063.     }
  2064.  
  2065.  
  2066.   return (xdata.start >= ydata.end || ydata.start >= xdata.end);
  2067. }
  2068.  
  2069. /* Similar, but calls decompose.  */
  2070.  
  2071. int
  2072. safe_from_earlyclobber (op, clobber)
  2073.      rtx op, clobber;
  2074. {
  2075.   struct decomposition early_data;
  2076.  
  2077.   early_data = decompose (clobber);
  2078.   return immune_p (op, clobber, early_data);
  2079. }
  2080.  
  2081. /* Main entry point of this file: search the body of INSN
  2082.    for values that need reloading and record them with push_reload.
  2083.    REPLACE nonzero means record also where the values occur
  2084.    so that subst_reloads can be used.
  2085.  
  2086.    IND_LEVELS says how many levels of indirection are supported by this
  2087.    machine; a value of zero means that a memory reference is not a valid
  2088.    memory address.
  2089.  
  2090.    LIVE_KNOWN says we have valid information about which hard
  2091.    regs are live at each point in the program; this is true when
  2092.    we are called from global_alloc but false when stupid register
  2093.    allocation has been done.
  2094.  
  2095.    RELOAD_REG_P if nonzero is a vector indexed by hard reg number
  2096.    which is nonnegative if the reg has been commandeered for reloading into.
  2097.    It is copied into STATIC_RELOAD_REG_P and referenced from there
  2098.    by various subroutines.  */
  2099.  
  2100. void
  2101. find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
  2102.      rtx insn;
  2103.      int replace, ind_levels;
  2104.      int live_known;
  2105.      short *reload_reg_p;
  2106. {
  2107. #ifdef REGISTER_CONSTRAINTS
  2108.  
  2109.   register int insn_code_number;
  2110.   register int i, j;
  2111.   int noperands;
  2112.   /* These are the constraints for the insn.  We don't change them.  */
  2113.   char *constraints1[MAX_RECOG_OPERANDS];
  2114.   /* These start out as the constraints for the insn
  2115.      and they are chewed up as we consider alternatives.  */
  2116.   char *constraints[MAX_RECOG_OPERANDS];
  2117.   /* These are the preferred classes for an operand, or NO_REGS if it isn't
  2118.      a register.  */
  2119.   enum reg_class preferred_class[MAX_RECOG_OPERANDS];
  2120.   char pref_or_nothing[MAX_RECOG_OPERANDS];
  2121.   /* Nonzero for a MEM operand whose entire address needs a reload.  */
  2122.   int address_reloaded[MAX_RECOG_OPERANDS];
  2123.   /* Value of enum reload_type to use for operand.  */
  2124.   enum reload_type operand_type[MAX_RECOG_OPERANDS];
  2125.   /* Value of enum reload_type to use within address of operand.  */
  2126.   enum reload_type address_type[MAX_RECOG_OPERANDS];
  2127.   /* Save the usage of each operand.  */
  2128.   enum reload_usage { RELOAD_READ, RELOAD_READ_WRITE, RELOAD_WRITE } modified[MAX_RECOG_OPERANDS];
  2129.   int no_input_reloads = 0, no_output_reloads = 0;
  2130.   int n_alternatives;
  2131.   int this_alternative[MAX_RECOG_OPERANDS];
  2132.   char this_alternative_win[MAX_RECOG_OPERANDS];
  2133.   char this_alternative_offmemok[MAX_RECOG_OPERANDS];
  2134.   char this_alternative_earlyclobber[MAX_RECOG_OPERANDS];
  2135.   int this_alternative_matches[MAX_RECOG_OPERANDS];
  2136.   int swapped;
  2137.   int goal_alternative[MAX_RECOG_OPERANDS];
  2138.   int this_alternative_number;
  2139.   int goal_alternative_number;
  2140.   int operand_reloadnum[MAX_RECOG_OPERANDS];
  2141.   int goal_alternative_matches[MAX_RECOG_OPERANDS];
  2142.   int goal_alternative_matched[MAX_RECOG_OPERANDS];
  2143.   char goal_alternative_win[MAX_RECOG_OPERANDS];
  2144.   char goal_alternative_offmemok[MAX_RECOG_OPERANDS];
  2145.   char goal_alternative_earlyclobber[MAX_RECOG_OPERANDS];
  2146.   int goal_alternative_swapped;
  2147.   int best;
  2148.   int commutative;
  2149.   char operands_match[MAX_RECOG_OPERANDS][MAX_RECOG_OPERANDS];
  2150.   rtx substed_operand[MAX_RECOG_OPERANDS];
  2151.   rtx body = PATTERN (insn);
  2152.   rtx set = single_set (insn);
  2153.   int goal_earlyclobber, this_earlyclobber;
  2154.   enum machine_mode operand_mode[MAX_RECOG_OPERANDS];
  2155.  
  2156.   this_insn = insn;
  2157.   this_insn_is_asm = 0;        /* Tentative.  */
  2158.   n_reloads = 0;
  2159.   n_replacements = 0;
  2160.   n_memlocs = 0;
  2161.   n_earlyclobbers = 0;
  2162.   replace_reloads = replace;
  2163.   hard_regs_live_known = live_known;
  2164.   static_reload_reg_p = reload_reg_p;
  2165.  
  2166.   /* JUMP_INSNs and CALL_INSNs are not allowed to have any output reloads;
  2167.      neither are insns that SET cc0.  Insns that use CC0 are not allowed
  2168.      to have any input reloads.  */
  2169.   if (GET_CODE (insn) == JUMP_INSN || GET_CODE (insn) == CALL_INSN)
  2170.     no_output_reloads = 1;
  2171.  
  2172. #ifdef HAVE_cc0
  2173.   if (reg_referenced_p (cc0_rtx, PATTERN (insn)))
  2174.     no_input_reloads = 1;
  2175.   if (reg_set_p (cc0_rtx, PATTERN (insn)))
  2176.     no_output_reloads = 1;
  2177. #endif
  2178.      
  2179. #ifdef SECONDARY_MEMORY_NEEDED
  2180.   /* The eliminated forms of any secondary memory locations are per-insn, so
  2181.      clear them out here.  */
  2182.  
  2183.   bzero ((char *) secondary_memlocs_elim, sizeof secondary_memlocs_elim);
  2184. #endif
  2185.  
  2186.   /* Find what kind of insn this is.  NOPERANDS gets number of operands.
  2187.      Make OPERANDS point to a vector of operand values.
  2188.      Make OPERAND_LOCS point to a vector of pointers to
  2189.      where the operands were found.
  2190.      Fill CONSTRAINTS and CONSTRAINTS1 with pointers to the
  2191.      constraint-strings for this insn.
  2192.      Return if the insn needs no reload processing.  */
  2193.  
  2194.   switch (GET_CODE (body))
  2195.     {
  2196.     case USE:
  2197.     case CLOBBER:
  2198.     case ASM_INPUT:
  2199.     case ADDR_VEC:
  2200.     case ADDR_DIFF_VEC:
  2201.       return;
  2202.  
  2203.     case SET:
  2204.       /* Dispose quickly of (set (reg..) (reg..)) if both have hard regs and it
  2205.      is cheap to move between them.  If it is not, there may not be an insn
  2206.      to do the copy, so we may need a reload.  */
  2207.       if (GET_CODE (SET_DEST (body)) == REG
  2208.       && REGNO (SET_DEST (body)) < FIRST_PSEUDO_REGISTER
  2209.       && GET_CODE (SET_SRC (body)) == REG
  2210.       && REGNO (SET_SRC (body)) < FIRST_PSEUDO_REGISTER
  2211.       && REGISTER_MOVE_COST (REGNO_REG_CLASS (REGNO (SET_SRC (body))),
  2212.                  REGNO_REG_CLASS (REGNO (SET_DEST (body)))) == 2)
  2213.     return;
  2214.     case PARALLEL:
  2215.     case ASM_OPERANDS:
  2216.       reload_n_operands = noperands = asm_noperands (body);
  2217.       if (noperands >= 0)
  2218.     {
  2219.       /* This insn is an `asm' with operands.  */
  2220.  
  2221.       insn_code_number = -1;
  2222.       this_insn_is_asm = 1;
  2223.  
  2224.       /* expand_asm_operands makes sure there aren't too many operands.  */
  2225.       if (noperands > MAX_RECOG_OPERANDS)
  2226.         abort ();
  2227.  
  2228.       /* Now get the operand values and constraints out of the insn.  */
  2229.  
  2230.       decode_asm_operands (body, recog_operand, recog_operand_loc,
  2231.                    constraints, operand_mode);
  2232.       if (noperands > 0)
  2233.         {
  2234.           bcopy ((char *) constraints, (char *) constraints1,
  2235.              noperands * sizeof (char *));
  2236.           n_alternatives = n_occurrences (',', constraints[0]) + 1;
  2237.           for (i = 1; i < noperands; i++)
  2238.         if (n_alternatives != n_occurrences (',', constraints[i]) + 1)
  2239.           {
  2240.             error_for_asm (insn, "operand constraints differ in number of alternatives");
  2241.             /* Avoid further trouble with this insn.  */
  2242.             PATTERN (insn) = gen_rtx (USE, VOIDmode, const0_rtx);
  2243.             n_reloads = 0;
  2244.             return;
  2245.           }
  2246.         }
  2247.       break;
  2248.     }
  2249.  
  2250.     default:
  2251.       /* Ordinary insn: recognize it, get the operands via insn_extract
  2252.      and get the constraints.  */
  2253.  
  2254.       insn_code_number = recog_memoized (insn);
  2255.       if (insn_code_number < 0)
  2256.     fatal_insn_not_found (insn);
  2257.  
  2258.       reload_n_operands = noperands = insn_n_operands[insn_code_number];
  2259.       n_alternatives = insn_n_alternatives[insn_code_number];
  2260.       /* Just return "no reloads" if insn has no operands with constraints.  */
  2261.       if (n_alternatives == 0)
  2262.     return;
  2263.       insn_extract (insn);
  2264.       for (i = 0; i < noperands; i++)
  2265.     {
  2266.       constraints[i] = constraints1[i]
  2267.         = insn_operand_constraint[insn_code_number][i];
  2268.       operand_mode[i] = insn_operand_mode[insn_code_number][i];
  2269.     }
  2270.     }
  2271.  
  2272.   if (noperands == 0)
  2273.     return;
  2274.  
  2275.   commutative = -1;
  2276.  
  2277.   /* If we will need to know, later, whether some pair of operands
  2278.      are the same, we must compare them now and save the result.
  2279.      Reloading the base and index registers will clobber them
  2280.      and afterward they will fail to match.  */
  2281.  
  2282.   for (i = 0; i < noperands; i++)
  2283.     {
  2284.       register char *p;
  2285.       register int c;
  2286.  
  2287.       substed_operand[i] = recog_operand[i];
  2288.       p = constraints[i];
  2289.  
  2290.       modified[i] = RELOAD_READ;
  2291.  
  2292.       /* Scan this operand's constraint to see if it is an output operand, 
  2293.      an in-out operand, is commutative, or should match another.  */
  2294.  
  2295.       while (c = *p++)
  2296.     {
  2297.       if (c == '=')
  2298.         modified[i] = RELOAD_WRITE;
  2299.       else if (c == '+')
  2300.         modified[i] = RELOAD_READ_WRITE;
  2301.       else if (c == '%')
  2302.         {
  2303.           /* The last operand should not be marked commutative.  */
  2304.           if (i == noperands - 1)
  2305.         {
  2306.           if (this_insn_is_asm)
  2307.             warning_for_asm (this_insn,
  2308.                      "`%%' constraint used with last operand");
  2309.           else
  2310.             abort ();
  2311.         }
  2312.           else
  2313.         commutative = i;
  2314.         }
  2315.       else if (c >= '0' && c <= '9')
  2316.         {
  2317.           c -= '0';
  2318.           operands_match[c][i]
  2319.         = operands_match_p (recog_operand[c], recog_operand[i]);
  2320.  
  2321.           /* An operand may not match itself.  */
  2322.           if (c == i)
  2323.         {
  2324.           if (this_insn_is_asm)
  2325.             warning_for_asm (this_insn,
  2326.                      "operand %d has constraint %d", i, c);
  2327.           else
  2328.             abort ();
  2329.         }
  2330.  
  2331.           /* If C can be commuted with C+1, and C might need to match I,
  2332.          then C+1 might also need to match I.  */
  2333.           if (commutative >= 0)
  2334.         {
  2335.           if (c == commutative || c == commutative + 1)
  2336.             {
  2337.               int other = c + (c == commutative ? 1 : -1);
  2338.               operands_match[other][i]
  2339.             = operands_match_p (recog_operand[other], recog_operand[i]);
  2340.             }
  2341.           if (i == commutative || i == commutative + 1)
  2342.             {
  2343.               int other = i + (i == commutative ? 1 : -1);
  2344.               operands_match[c][other]
  2345.             = operands_match_p (recog_operand[c], recog_operand[other]);
  2346.             }
  2347.           /* Note that C is supposed to be less than I.
  2348.              No need to consider altering both C and I because in
  2349.              that case we would alter one into the other.  */
  2350.         }
  2351.         }
  2352.     }
  2353.     }
  2354.  
  2355.   /* Examine each operand that is a memory reference or memory address
  2356.      and reload parts of the addresses into index registers.
  2357.      Also here any references to pseudo regs that didn't get hard regs
  2358.      but are equivalent to constants get replaced in the insn itself
  2359.      with those constants.  Nobody will ever see them again. 
  2360.  
  2361.      Finally, set up the preferred classes of each operand.  */
  2362.  
  2363.   for (i = 0; i < noperands; i++)
  2364.     {
  2365.       register RTX_CODE code = GET_CODE (recog_operand[i]);
  2366.  
  2367.       address_reloaded[i] = 0;
  2368.       operand_type[i] = (modified[i] == RELOAD_READ ? RELOAD_FOR_INPUT
  2369.              : modified[i] == RELOAD_WRITE ? RELOAD_FOR_OUTPUT
  2370.              : RELOAD_OTHER);
  2371.       address_type[i]
  2372.     = (modified[i] == RELOAD_READ ? RELOAD_FOR_INPUT_ADDRESS
  2373.        : modified[i] == RELOAD_WRITE ? RELOAD_FOR_OUTPUT_ADDRESS
  2374.        : RELOAD_OTHER);
  2375.  
  2376.       if (*constraints[i] == 0)
  2377.     /* Ignore things like match_operator operands.  */
  2378.     ;
  2379.       else if (constraints[i][0] == 'p')
  2380.     {
  2381.       find_reloads_address (VOIDmode, NULL_PTR,
  2382.                 recog_operand[i], recog_operand_loc[i],
  2383.                 i, operand_type[i], ind_levels);
  2384.       substed_operand[i] = recog_operand[i] = *recog_operand_loc[i];
  2385.     }
  2386.       else if (code == MEM)
  2387.     {
  2388.       if (find_reloads_address (GET_MODE (recog_operand[i]),
  2389.                     recog_operand_loc[i],
  2390.                     XEXP (recog_operand[i], 0),
  2391.                     &XEXP (recog_operand[i], 0),
  2392.                     i, address_type[i], ind_levels))
  2393.         address_reloaded[i] = 1;
  2394.       substed_operand[i] = recog_operand[i] = *recog_operand_loc[i];
  2395.     }
  2396.       else if (code == SUBREG)
  2397.     substed_operand[i] = recog_operand[i] = *recog_operand_loc[i]
  2398.       = find_reloads_toplev (recog_operand[i], i, address_type[i],
  2399.                  ind_levels,
  2400.                  set != 0
  2401.                  && &SET_DEST (set) == recog_operand_loc[i]);
  2402.       else if (code == PLUS)
  2403.     /* We can get a PLUS as an "operand" as a result of
  2404.        register elimination.  See eliminate_regs and gen_input_reload.  */
  2405.     substed_operand[i] = recog_operand[i] = *recog_operand_loc[i]
  2406.       = find_reloads_toplev (recog_operand[i], i, address_type[i],
  2407.                  ind_levels, 0);
  2408.       else if (code == REG)
  2409.     {
  2410.       /* This is equivalent to calling find_reloads_toplev.
  2411.          The code is duplicated for speed.
  2412.          When we find a pseudo always equivalent to a constant,
  2413.          we replace it by the constant.  We must be sure, however,
  2414.          that we don't try to replace it in the insn in which it
  2415.          is being set.   */
  2416.       register int regno = REGNO (recog_operand[i]);
  2417.       if (reg_equiv_constant[regno] != 0
  2418.           && (set == 0 || &SET_DEST (set) != recog_operand_loc[i]))
  2419.         substed_operand[i] = recog_operand[i]
  2420.           = reg_equiv_constant[regno];
  2421. #if 0 /* This might screw code in reload1.c to delete prior output-reload
  2422.      that feeds this insn.  */
  2423.       if (reg_equiv_mem[regno] != 0)
  2424.         substed_operand[i] = recog_operand[i]
  2425.           = reg_equiv_mem[regno];
  2426. #endif
  2427.       if (reg_equiv_address[regno] != 0)
  2428.         {
  2429.           /* If reg_equiv_address is not a constant address, copy it,
  2430.          since it may be shared.  */
  2431.           rtx address = reg_equiv_address[regno];
  2432.  
  2433.           if (rtx_varies_p (address))
  2434.         address = copy_rtx (address);
  2435.  
  2436.           /* If this is an output operand, we must output a CLOBBER
  2437.          after INSN so find_equiv_reg knows REGNO is being written. 
  2438.          Mark this insn specially, do we can put our output reloads
  2439.          after it.  */
  2440.  
  2441.           if (modified[i] != RELOAD_READ)
  2442.         PUT_MODE (emit_insn_after (gen_rtx (CLOBBER, VOIDmode,
  2443.                             recog_operand[i]),
  2444.                        insn),
  2445.               DImode);
  2446.  
  2447.           *recog_operand_loc[i] = recog_operand[i]
  2448.         = gen_rtx (MEM, GET_MODE (recog_operand[i]), address);
  2449.           RTX_UNCHANGING_P (recog_operand[i])
  2450.         = RTX_UNCHANGING_P (regno_reg_rtx[regno]);
  2451.           find_reloads_address (GET_MODE (recog_operand[i]),
  2452.                     recog_operand_loc[i],
  2453.                     XEXP (recog_operand[i], 0),
  2454.                     &XEXP (recog_operand[i], 0),
  2455.                     i, address_type[i], ind_levels);
  2456.           substed_operand[i] = recog_operand[i] = *recog_operand_loc[i];
  2457.         }
  2458.     }
  2459.       /* If the operand is still a register (we didn't replace it with an
  2460.      equivalent), get the preferred class to reload it into.  */
  2461.       code = GET_CODE (recog_operand[i]);
  2462.       preferred_class[i]
  2463.     = ((code == REG && REGNO (recog_operand[i]) >= FIRST_PSEUDO_REGISTER)
  2464.        ? reg_preferred_class (REGNO (recog_operand[i])) : NO_REGS);
  2465.       pref_or_nothing[i]
  2466.     = (code == REG && REGNO (recog_operand[i]) >= FIRST_PSEUDO_REGISTER
  2467.        && reg_alternate_class (REGNO (recog_operand[i])) == NO_REGS);
  2468.     }
  2469.  
  2470.   /* If this is simply a copy from operand 1 to operand 0, merge the
  2471.      preferred classes for the operands.  */
  2472.   if (set != 0 && noperands >= 2 && recog_operand[0] == SET_DEST (set)
  2473.       && recog_operand[1] == SET_SRC (set))
  2474.     {
  2475.       preferred_class[0] = preferred_class[1]
  2476.     = reg_class_subunion[(int) preferred_class[0]][(int) preferred_class[1]];
  2477.       pref_or_nothing[0] |= pref_or_nothing[1];
  2478.       pref_or_nothing[1] |= pref_or_nothing[0];
  2479.     }
  2480.  
  2481.   /* Now see what we need for pseudo-regs that didn't get hard regs
  2482.      or got the wrong kind of hard reg.  For this, we must consider
  2483.      all the operands together against the register constraints.  */
  2484.  
  2485.   best = MAX_RECOG_OPERANDS + 300;
  2486.  
  2487.   swapped = 0;
  2488.   goal_alternative_swapped = 0;
  2489.  try_swapped:
  2490.  
  2491.   /* The constraints are made of several alternatives.
  2492.      Each operand's constraint looks like foo,bar,... with commas
  2493.      separating the alternatives.  The first alternatives for all
  2494.      operands go together, the second alternatives go together, etc.
  2495.  
  2496.      First loop over alternatives.  */
  2497.  
  2498.   for (this_alternative_number = 0;
  2499.        this_alternative_number < n_alternatives;
  2500.        this_alternative_number++)
  2501.     {
  2502.       /* Loop over operands for one constraint alternative.  */
  2503.       /* LOSERS counts those that don't fit this alternative
  2504.      and would require loading.  */
  2505.       int losers = 0;
  2506.       /* BAD is set to 1 if it some operand can't fit this alternative
  2507.      even after reloading.  */
  2508.       int bad = 0;
  2509.       /* REJECT is a count of how undesirable this alternative says it is
  2510.      if any reloading is required.  If the alternative matches exactly
  2511.      then REJECT is ignored, but otherwise it gets this much
  2512.      counted against it in addition to the reloading needed.  Each 
  2513.      ? counts three times here since we want the disparaging caused by
  2514.      a bad register class to only count 1/3 as much.  */
  2515.       int reject = 0;
  2516.  
  2517.       this_earlyclobber = 0;
  2518.  
  2519.       for (i = 0; i < noperands; i++)
  2520.     {
  2521.       register char *p = constraints[i];
  2522.       register int win = 0;
  2523.       /* 0 => this operand can be reloaded somehow for this alternative */
  2524.       int badop = 1;
  2525.       /* 0 => this operand can be reloaded if the alternative allows regs.  */
  2526.       int winreg = 0;
  2527.       int c;
  2528.       register rtx operand = recog_operand[i];
  2529.       int offset = 0;
  2530.       /* Nonzero means this is a MEM that must be reloaded into a reg
  2531.          regardless of what the constraint says.  */
  2532.       int force_reload = 0;
  2533.       int offmemok = 0;
  2534.       /* Nonzero if a constant forced into memory would be OK for this
  2535.          operand.  */
  2536.       int constmemok = 0;
  2537.       int earlyclobber = 0;
  2538.  
  2539.       /* If the operand is a SUBREG, extract
  2540.          the REG or MEM (or maybe even a constant) within.
  2541.          (Constants can occur as a result of reg_equiv_constant.)  */
  2542.  
  2543.       while (GET_CODE (operand) == SUBREG)
  2544.         {
  2545.           offset += SUBREG_WORD (operand);
  2546.           operand = SUBREG_REG (operand);
  2547.           /* Force reload if this is a constant or PLUS or if there may may
  2548.          be a problem accessing OPERAND in the outer mode.  */
  2549.           if (CONSTANT_P (operand)
  2550.           || GET_CODE (operand) == PLUS
  2551.           /* We must force a reload of paradoxical SUBREGs
  2552.              of a MEM because the alignment of the inner value
  2553.              may not be enough to do the outer reference.
  2554.  
  2555.              On machines that extend byte operations and we have a
  2556.              SUBREG where both the inner and outer modes are different
  2557.              size but no wider than a word, combine.c has made
  2558.              assumptions about the behavior of the machine in such
  2559.              register access.  If the data is, in fact, in memory we
  2560.              must always load using the size assumed to be in the
  2561.              register and let the insn do the different-sized 
  2562.              accesses.  */
  2563.           || ((GET_CODE (operand) == MEM
  2564.                || (GET_CODE (operand)== REG
  2565.                && REGNO (operand) >= FIRST_PSEUDO_REGISTER))
  2566.               && (((GET_MODE_BITSIZE (GET_MODE (operand))
  2567.                 < BIGGEST_ALIGNMENT)
  2568.                && (GET_MODE_SIZE (operand_mode[i])
  2569.                    > GET_MODE_SIZE (GET_MODE (operand))))
  2570. #ifdef LOAD_EXTEND_OP
  2571.               || (GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD
  2572.                   && (GET_MODE_SIZE (GET_MODE (operand))
  2573.                   <= UNITS_PER_WORD)
  2574.                   && (GET_MODE_SIZE (operand_mode[i])
  2575.                   != GET_MODE_SIZE (GET_MODE (operand))))
  2576. #endif
  2577.               ))
  2578.           /* Subreg of a hard reg which can't handle the subreg's mode
  2579.              or which would handle that mode in the wrong number of
  2580.              registers for subregging to work.  */
  2581.           || (GET_CODE (operand) == REG
  2582.               && REGNO (operand) < FIRST_PSEUDO_REGISTER
  2583.               && ((GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD
  2584.                && (GET_MODE_SIZE (GET_MODE (operand))
  2585.                    > UNITS_PER_WORD)
  2586.                && ((GET_MODE_SIZE (GET_MODE (operand))
  2587.                 / UNITS_PER_WORD)
  2588.                    != HARD_REGNO_NREGS (REGNO (operand),
  2589.                             GET_MODE (operand))))
  2590.               || ! HARD_REGNO_MODE_OK (REGNO (operand) + offset,
  2591.                            operand_mode[i]))))
  2592.         force_reload = 1;
  2593.         }
  2594.  
  2595.       this_alternative[i] = (int) NO_REGS;
  2596.       this_alternative_win[i] = 0;
  2597.       this_alternative_offmemok[i] = 0;
  2598.       this_alternative_earlyclobber[i] = 0;
  2599.       this_alternative_matches[i] = -1;
  2600.  
  2601.       /* An empty constraint or empty alternative
  2602.          allows anything which matched the pattern.  */
  2603.       if (*p == 0 || *p == ',')
  2604.         win = 1, badop = 0;
  2605.  
  2606.       /* Scan this alternative's specs for this operand;
  2607.          set WIN if the operand fits any letter in this alternative.
  2608.          Otherwise, clear BADOP if this operand could
  2609.          fit some letter after reloads,
  2610.          or set WINREG if this operand could fit after reloads
  2611.          provided the constraint allows some registers.  */
  2612.  
  2613.       while (*p && (c = *p++) != ',')
  2614.         switch (c)
  2615.           {
  2616.           case '=':
  2617.           case '+':
  2618.           case '*':
  2619.         break;
  2620.  
  2621.           case '%':
  2622.         /* The last operand should not be marked commutative.  */
  2623.         if (i != noperands - 1)
  2624.           commutative = i;
  2625.         break;
  2626.  
  2627.           case '?':
  2628.         reject += 3;
  2629.         break;
  2630.  
  2631.           case '!':
  2632.         reject = 300;
  2633.         break;
  2634.  
  2635.           case '#':
  2636.         /* Ignore rest of this alternative as far as
  2637.            reloading is concerned.  */
  2638.         while (*p && *p != ',') p++;
  2639.         break;
  2640.  
  2641.           case '0':
  2642.           case '1':
  2643.           case '2':
  2644.           case '3':
  2645.           case '4':
  2646.         c -= '0';
  2647.         this_alternative_matches[i] = c;
  2648.         /* We are supposed to match a previous operand.
  2649.            If we do, we win if that one did.
  2650.            If we do not, count both of the operands as losers.
  2651.            (This is too conservative, since most of the time
  2652.            only a single reload insn will be needed to make
  2653.            the two operands win.  As a result, this alternative
  2654.            may be rejected when it is actually desirable.)  */
  2655.         if ((swapped && (c != commutative || i != commutative + 1))
  2656.             /* If we are matching as if two operands were swapped,
  2657.                also pretend that operands_match had been computed
  2658.                with swapped.
  2659.                But if I is the second of those and C is the first,
  2660.                don't exchange them, because operands_match is valid
  2661.                only on one side of its diagonal.  */
  2662.             ? (operands_match
  2663.                 [(c == commutative || c == commutative + 1)
  2664.              ? 2*commutative + 1 - c : c]
  2665.                 [(i == commutative || i == commutative + 1)
  2666.              ? 2*commutative + 1 - i : i])
  2667.             : operands_match[c][i])
  2668.           win = this_alternative_win[c];
  2669.         else
  2670.           {
  2671.             /* Operands don't match.  */
  2672.             rtx value;
  2673.             /* Retroactively mark the operand we had to match
  2674.                as a loser, if it wasn't already.  */
  2675.             if (this_alternative_win[c])
  2676.               losers++;
  2677.             this_alternative_win[c] = 0;
  2678.             if (this_alternative[c] == (int) NO_REGS)
  2679.               bad = 1;
  2680.             /* But count the pair only once in the total badness of
  2681.                this alternative, if the pair can be a dummy reload.  */
  2682.             value
  2683.               = find_dummy_reload (recog_operand[i], recog_operand[c],
  2684.                        recog_operand_loc[i], recog_operand_loc[c],
  2685.                        operand_mode[i], operand_mode[c],
  2686.                        this_alternative[c], -1);
  2687.  
  2688.             if (value != 0)
  2689.               losers--;
  2690.           }
  2691.         /* This can be fixed with reloads if the operand
  2692.            we are supposed to match can be fixed with reloads.  */
  2693.         badop = 0;
  2694.         this_alternative[i] = this_alternative[c];
  2695.  
  2696.         /* If we have to reload this operand and some previous
  2697.            operand also had to match the same thing as this
  2698.            operand, we don't know how to do that.  So reject this
  2699.            alternative.  */
  2700.         if (! win || force_reload)
  2701.           for (j = 0; j < i; j++)
  2702.             if (this_alternative_matches[j]
  2703.             == this_alternative_matches[i])
  2704.               badop = 1;
  2705.  
  2706.         break;
  2707.  
  2708.           case 'p':
  2709.         /* All necessary reloads for an address_operand
  2710.            were handled in find_reloads_address.  */
  2711.         this_alternative[i] = (int) ALL_REGS;
  2712.         win = 1;
  2713.         break;
  2714.  
  2715.           case 'm':
  2716.         if (force_reload)
  2717.           break;
  2718.         if (GET_CODE (operand) == MEM
  2719.             || (GET_CODE (operand) == REG
  2720.             && REGNO (operand) >= FIRST_PSEUDO_REGISTER
  2721.             && reg_renumber[REGNO (operand)] < 0))
  2722.           win = 1;
  2723.         if (CONSTANT_P (operand))
  2724.           badop = 0;
  2725.         constmemok = 1;
  2726.         break;
  2727.  
  2728.           case '<':
  2729.         if (GET_CODE (operand) == MEM
  2730.             && ! address_reloaded[i]
  2731.             && (GET_CODE (XEXP (operand, 0)) == PRE_DEC
  2732.             || GET_CODE (XEXP (operand, 0)) == POST_DEC))
  2733.           win = 1;
  2734.         break;
  2735.  
  2736.           case '>':
  2737.         if (GET_CODE (operand) == MEM
  2738.             && ! address_reloaded[i]
  2739.             && (GET_CODE (XEXP (operand, 0)) == PRE_INC
  2740.             || GET_CODE (XEXP (operand, 0)) == POST_INC))
  2741.           win = 1;
  2742.         break;
  2743.  
  2744.         /* Memory operand whose address is not offsettable.  */
  2745.           case 'V':
  2746.         if (force_reload)
  2747.           break;
  2748.         if (GET_CODE (operand) == MEM
  2749.             && ! (ind_levels ? offsettable_memref_p (operand)
  2750.               : offsettable_nonstrict_memref_p (operand))
  2751.             /* Certain mem addresses will become offsettable
  2752.                after they themselves are reloaded.  This is important;
  2753.                we don't want our own handling of unoffsettables
  2754.                to override the handling of reg_equiv_address.  */
  2755.             && !(GET_CODE (XEXP (operand, 0)) == REG
  2756.              && (ind_levels == 0
  2757.                  || reg_equiv_address[REGNO (XEXP (operand, 0))] != 0)))
  2758.           win = 1;
  2759.         break;
  2760.  
  2761.         /* Memory operand whose address is offsettable.  */
  2762.           case 'o':
  2763.         if (force_reload)
  2764.           break;
  2765.         if ((GET_CODE (operand) == MEM
  2766.              /* If IND_LEVELS, find_reloads_address won't reload a
  2767.             pseudo that didn't get a hard reg, so we have to
  2768.             reject that case.  */
  2769.              && (ind_levels ? offsettable_memref_p (operand)
  2770.              : offsettable_nonstrict_memref_p (operand)))
  2771.             /* Certain mem addresses will become offsettable
  2772.                after they themselves are reloaded.  This is important;
  2773.                we don't want our own handling of unoffsettables
  2774.                to override the handling of reg_equiv_address.  */
  2775.             || (GET_CODE (operand) == MEM
  2776.             && GET_CODE (XEXP (operand, 0)) == REG
  2777.             && (ind_levels == 0
  2778.                 || reg_equiv_address[REGNO (XEXP (operand, 0))] != 0))
  2779.             || (GET_CODE (operand) == REG
  2780.             && REGNO (operand) >= FIRST_PSEUDO_REGISTER
  2781.             && reg_renumber[REGNO (operand)] < 0
  2782.             /* If reg_equiv_address is nonzero, we will be
  2783.                loading it into a register; hence it will be
  2784.                offsettable, but we cannot say that reg_equiv_mem
  2785.                is offsettable without checking.  */
  2786.             && ((reg_equiv_mem[REGNO (operand)] != 0
  2787.                  && offsettable_memref_p (reg_equiv_mem[REGNO (operand)]))
  2788.                 || (reg_equiv_address[REGNO (operand)] != 0))))
  2789.           win = 1;
  2790.         if (CONSTANT_P (operand) || GET_CODE (operand) == MEM)
  2791.           badop = 0;
  2792.         constmemok = 1;
  2793.         offmemok = 1;
  2794.         break;
  2795.  
  2796.           case '&':
  2797.         /* Output operand that is stored before the need for the
  2798.            input operands (and their index registers) is over.  */
  2799.         earlyclobber = 1, this_earlyclobber = 1;
  2800.         break;
  2801.  
  2802.           case 'E':
  2803.         /* Match any floating double constant, but only if
  2804.            we can examine the bits of it reliably.  */
  2805.         if ((HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  2806.              || HOST_BITS_PER_WIDE_INT != BITS_PER_WORD)
  2807.             && GET_MODE (operand) != VOIDmode && ! flag_pretend_float)
  2808.           break;
  2809.         if (GET_CODE (operand) == CONST_DOUBLE)
  2810.           win = 1;
  2811.         break;
  2812.  
  2813.           case 'F':
  2814.         if (GET_CODE (operand) == CONST_DOUBLE)
  2815.           win = 1;
  2816.         break;
  2817.  
  2818.           case 'G':
  2819.           case 'H':
  2820.         if (GET_CODE (operand) == CONST_DOUBLE
  2821.             && CONST_DOUBLE_OK_FOR_LETTER_P (operand, c))
  2822.           win = 1;
  2823.         break;
  2824.  
  2825.           case 's':
  2826.         if (GET_CODE (operand) == CONST_INT
  2827.             || (GET_CODE (operand) == CONST_DOUBLE
  2828.             && GET_MODE (operand) == VOIDmode))
  2829.           break;
  2830.           case 'i':
  2831.         if (CONSTANT_P (operand)
  2832. #ifdef LEGITIMATE_PIC_OPERAND_P
  2833.             && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (operand))
  2834. #endif
  2835.             )
  2836.           win = 1;
  2837.         break;
  2838.  
  2839.           case 'n':
  2840.         if (GET_CODE (operand) == CONST_INT
  2841.             || (GET_CODE (operand) == CONST_DOUBLE
  2842.             && GET_MODE (operand) == VOIDmode))
  2843.           win = 1;
  2844.         break;
  2845.  
  2846.           case 'I':
  2847.           case 'J':
  2848.           case 'K':
  2849.           case 'L':
  2850.           case 'M':
  2851.           case 'N':
  2852.           case 'O':
  2853.           case 'P':
  2854.         if (GET_CODE (operand) == CONST_INT
  2855.             && CONST_OK_FOR_LETTER_P (INTVAL (operand), c))
  2856.           win = 1;
  2857.         break;
  2858.  
  2859.           case 'X':
  2860.         win = 1;
  2861.         break;
  2862.  
  2863.           case 'g':
  2864.         if (! force_reload
  2865.             /* A PLUS is never a valid operand, but reload can make
  2866.                it from a register when eliminating registers.  */
  2867.             && GET_CODE (operand) != PLUS
  2868.             /* A SCRATCH is not a valid operand.  */
  2869.             && GET_CODE (operand) != SCRATCH
  2870. #ifdef LEGITIMATE_PIC_OPERAND_P
  2871.             && (! CONSTANT_P (operand) 
  2872.             || ! flag_pic 
  2873.             || LEGITIMATE_PIC_OPERAND_P (operand))
  2874. #endif
  2875.             && (GENERAL_REGS == ALL_REGS
  2876.             || GET_CODE (operand) != REG
  2877.             || (REGNO (operand) >= FIRST_PSEUDO_REGISTER
  2878.                 && reg_renumber[REGNO (operand)] < 0)))
  2879.           win = 1;
  2880.         /* Drop through into 'r' case */
  2881.  
  2882.           case 'r':
  2883.         this_alternative[i]
  2884.           = (int) reg_class_subunion[this_alternative[i]][(int) GENERAL_REGS];
  2885.         goto reg;
  2886.  
  2887. #ifdef EXTRA_CONSTRAINT
  2888.               case 'Q':
  2889.               case 'R':
  2890.               case 'S':
  2891.               case 'T':
  2892.               case 'U':
  2893.         if (EXTRA_CONSTRAINT (operand, c))
  2894.           win = 1;
  2895.         break;
  2896. #endif
  2897.   
  2898.           default:
  2899.         this_alternative[i]
  2900.           = (int) reg_class_subunion[this_alternative[i]][(int) REG_CLASS_FROM_LETTER (c)];
  2901.         
  2902.           reg:
  2903.         if (GET_MODE (operand) == BLKmode)
  2904.           break;
  2905.         winreg = 1;
  2906.         if (GET_CODE (operand) == REG
  2907.             && reg_fits_class_p (operand, this_alternative[i],
  2908.                      offset, GET_MODE (recog_operand[i])))
  2909.           win = 1;
  2910.         break;
  2911.           }
  2912.  
  2913.       constraints[i] = p;
  2914.  
  2915.       /* If this operand could be handled with a reg,
  2916.          and some reg is allowed, then this operand can be handled.  */
  2917.       if (winreg && this_alternative[i] != (int) NO_REGS)
  2918.         badop = 0;
  2919.  
  2920.       /* Record which operands fit this alternative.  */
  2921.       this_alternative_earlyclobber[i] = earlyclobber;
  2922.       if (win && ! force_reload)
  2923.         this_alternative_win[i] = 1;
  2924.       else
  2925.         {
  2926.           int const_to_mem = 0;
  2927.  
  2928.           this_alternative_offmemok[i] = offmemok;
  2929.           losers++;
  2930.           if (badop)
  2931.         bad = 1;
  2932.           /* Alternative loses if it has no regs for a reg operand.  */
  2933.           if (GET_CODE (operand) == REG
  2934.           && this_alternative[i] == (int) NO_REGS
  2935.           && this_alternative_matches[i] < 0)
  2936.         bad = 1;
  2937.  
  2938.           /* Alternative loses if it requires a type of reload not
  2939.          permitted for this insn.  We can always reload SCRATCH
  2940.          and objects with a REG_UNUSED note.  */
  2941.           if (GET_CODE (operand) != SCRATCH
  2942.           && modified[i] != RELOAD_READ && no_output_reloads
  2943.           && ! find_reg_note (insn, REG_UNUSED, operand))
  2944.         bad = 1;
  2945.           else if (modified[i] != RELOAD_WRITE && no_input_reloads)
  2946.         bad = 1;
  2947.  
  2948.           /* If this is a constant that is reloaded into the desired
  2949.          class by copying it to memory first, count that as another
  2950.          reload.  This is consistent with other code and is
  2951.          required to avoid chosing another alternative when
  2952.          the constant is moved into memory by this function on
  2953.          an early reload pass.  Note that the test here is 
  2954.          precisely the same as in the code below that calls
  2955.          force_const_mem.  */
  2956.           if (CONSTANT_P (operand)
  2957.           /* force_const_mem does not accept HIGH.  */
  2958.           && GET_CODE (operand) != HIGH
  2959.           && (PREFERRED_RELOAD_CLASS (operand,
  2960.                           (enum reg_class) this_alternative[i])
  2961.               == NO_REGS)
  2962.           && operand_mode[i] != VOIDmode)
  2963.         {
  2964.           const_to_mem = 1;
  2965.           if (this_alternative[i] != (int) NO_REGS)
  2966.             losers++;
  2967.         }
  2968.  
  2969.           /* If we can't reload this value at all, reject this
  2970.          alternative.  Note that we could also lose due to
  2971.          LIMIT_RELOAD_RELOAD_CLASS, but we don't check that
  2972.          here.  */
  2973.  
  2974.           if (! CONSTANT_P (operand)
  2975.           && (enum reg_class) this_alternative[i] != NO_REGS
  2976.           && (PREFERRED_RELOAD_CLASS (operand,
  2977.                           (enum reg_class) this_alternative[i])
  2978.               == NO_REGS))
  2979.         bad = 1;
  2980.  
  2981.           /* We prefer to reload pseudos over reloading other things,
  2982.          since such reloads may be able to be eliminated later.
  2983.          If we are reloading a SCRATCH, we won't be generating any
  2984.          insns, just using a register, so it is also preferred. 
  2985.          So bump REJECT in other cases.  Don't do this in the
  2986.          case where we are forcing a constant into memory and
  2987.          it will then win since we don't want to have a different
  2988.          alternative match then.  */
  2989.           if (! (GET_CODE (operand) == REG
  2990.              && REGNO (operand) >= FIRST_PSEUDO_REGISTER)
  2991.           && GET_CODE (operand) != SCRATCH
  2992.           && ! (const_to_mem && constmemok))
  2993.         reject++;
  2994.         }
  2995.  
  2996.       /* If this operand is a pseudo register that didn't get a hard 
  2997.          reg and this alternative accepts some register, see if the
  2998.          class that we want is a subset of the preferred class for this
  2999.          register.  If not, but it intersects that class, use the
  3000.          preferred class instead.  If it does not intersect the preferred
  3001.          class, show that usage of this alternative should be discouraged;
  3002.          it will be discouraged more still if the register is `preferred
  3003.          or nothing'.  We do this because it increases the chance of
  3004.          reusing our spill register in a later insn and avoiding a pair
  3005.          of memory stores and loads.
  3006.  
  3007.          Don't bother with this if this alternative will accept this
  3008.          operand.
  3009.  
  3010.          Don't do this for a multiword operand, since it is only a
  3011.          small win and has the risk of requiring more spill registers,
  3012.          which could cause a large loss.
  3013.  
  3014.          Don't do this if the preferred class has only one register
  3015.          because we might otherwise exhaust the class.  */
  3016.  
  3017.  
  3018.       if (! win && this_alternative[i] != (int) NO_REGS
  3019.           && GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD
  3020.           && reg_class_size[(int) preferred_class[i]] > 1)
  3021.         {
  3022.           if (! reg_class_subset_p (this_alternative[i],
  3023.                     preferred_class[i]))
  3024.         {
  3025.           /* Since we don't have a way of forming the intersection,
  3026.              we just do something special if the preferred class
  3027.              is a subset of the class we have; that's the most 
  3028.              common case anyway.  */
  3029.           if (reg_class_subset_p (preferred_class[i],
  3030.                       this_alternative[i]))
  3031.             this_alternative[i] = (int) preferred_class[i];
  3032.           else
  3033.             reject += (1 + pref_or_nothing[i]);
  3034.         }
  3035.         }
  3036.     }
  3037.  
  3038.       /* Now see if any output operands that are marked "earlyclobber"
  3039.      in this alternative conflict with any input operands
  3040.      or any memory addresses.  */
  3041.  
  3042.       for (i = 0; i < noperands; i++)
  3043.     if (this_alternative_earlyclobber[i]
  3044.         && this_alternative_win[i])
  3045.       {
  3046.         struct decomposition early_data; 
  3047.  
  3048.         early_data = decompose (recog_operand[i]);
  3049.  
  3050.         if (modified[i] == RELOAD_READ)
  3051.           {
  3052.         if (this_insn_is_asm)
  3053.           warning_for_asm (this_insn,
  3054.                    "`&' constraint used with input operand");
  3055.         else
  3056.           abort ();
  3057.         continue;
  3058.           }
  3059.         
  3060.         if (this_alternative[i] == NO_REGS)
  3061.           {
  3062.         this_alternative_earlyclobber[i] = 0;
  3063.         if (this_insn_is_asm)
  3064.           error_for_asm (this_insn,
  3065.                  "`&' constraint used with no register class");
  3066.         else
  3067.           abort ();
  3068.           }
  3069.  
  3070.         for (j = 0; j < noperands; j++)
  3071.           /* Is this an input operand or a memory ref?  */
  3072.           if ((GET_CODE (recog_operand[j]) == MEM
  3073.            || modified[j] != RELOAD_WRITE)
  3074.           && j != i
  3075.           /* Ignore things like match_operator operands.  */
  3076.           && *constraints1[j] != 0
  3077.           /* Don't count an input operand that is constrained to match
  3078.              the early clobber operand.  */
  3079.           && ! (this_alternative_matches[j] == i
  3080.             && rtx_equal_p (recog_operand[i], recog_operand[j]))
  3081.           /* Is it altered by storing the earlyclobber operand?  */
  3082.           && !immune_p (recog_operand[j], recog_operand[i], early_data))
  3083.         {
  3084.           /* If the output is in a single-reg class,
  3085.              it's costly to reload it, so reload the input instead.  */
  3086.           if (reg_class_size[this_alternative[i]] == 1
  3087.               && (GET_CODE (recog_operand[j]) == REG
  3088.               || GET_CODE (recog_operand[j]) == SUBREG))
  3089.             {
  3090.               losers++;
  3091.               this_alternative_win[j] = 0;
  3092.             }
  3093.           else
  3094.             break;
  3095.         }
  3096.         /* If an earlyclobber operand conflicts with something,
  3097.            it must be reloaded, so request this and count the cost.  */
  3098.         if (j != noperands)
  3099.           {
  3100.         losers++;
  3101.         this_alternative_win[i] = 0;
  3102.         for (j = 0; j < noperands; j++)
  3103.           if (this_alternative_matches[j] == i
  3104.               && this_alternative_win[j])
  3105.             {
  3106.               this_alternative_win[j] = 0;
  3107.               losers++;
  3108.             }
  3109.           }
  3110.       }
  3111.  
  3112.       /* If one alternative accepts all the operands, no reload required,
  3113.      choose that alternative; don't consider the remaining ones.  */
  3114.       if (losers == 0)
  3115.     {
  3116.       /* Unswap these so that they are never swapped at `finish'.  */
  3117.       if (commutative >= 0)
  3118.         {
  3119.           recog_operand[commutative] = substed_operand[commutative];
  3120.           recog_operand[commutative + 1]
  3121.         = substed_operand[commutative + 1];
  3122.         }
  3123.       for (i = 0; i < noperands; i++)
  3124.         {
  3125.           goal_alternative_win[i] = 1;
  3126.           goal_alternative[i] = this_alternative[i];
  3127.           goal_alternative_offmemok[i] = this_alternative_offmemok[i];
  3128.           goal_alternative_matches[i] = this_alternative_matches[i];
  3129.           goal_alternative_earlyclobber[i]
  3130.         = this_alternative_earlyclobber[i];
  3131.         }
  3132.       goal_alternative_number = this_alternative_number;
  3133.       goal_alternative_swapped = swapped;
  3134.       goal_earlyclobber = this_earlyclobber;
  3135.       goto finish;
  3136.     }
  3137.  
  3138.       /* REJECT, set by the ! and ? constraint characters and when a register
  3139.      would be reloaded into a non-preferred class, discourages the use of
  3140.      this alternative for a reload goal.  REJECT is incremented by three
  3141.      for each ? and one for each non-preferred class.  */
  3142.       losers = losers * 3 + reject;
  3143.  
  3144.       /* If this alternative can be made to work by reloading,
  3145.      and it needs less reloading than the others checked so far,
  3146.      record it as the chosen goal for reloading.  */
  3147.       if (! bad && best > losers)
  3148.     {
  3149.       for (i = 0; i < noperands; i++)
  3150.         {
  3151.           goal_alternative[i] = this_alternative[i];
  3152.           goal_alternative_win[i] = this_alternative_win[i];
  3153.           goal_alternative_offmemok[i] = this_alternative_offmemok[i];
  3154.           goal_alternative_matches[i] = this_alternative_matches[i];
  3155.           goal_alternative_earlyclobber[i]
  3156.         = this_alternative_earlyclobber[i];
  3157.         }
  3158.       goal_alternative_swapped = swapped;
  3159.       best = losers;
  3160.       goal_alternative_number = this_alternative_number;
  3161.       goal_earlyclobber = this_earlyclobber;
  3162.     }
  3163.     }
  3164.  
  3165.   /* If insn is commutative (it's safe to exchange a certain pair of operands)
  3166.      then we need to try each alternative twice,
  3167.      the second time matching those two operands
  3168.      as if we had exchanged them.
  3169.      To do this, really exchange them in operands.
  3170.  
  3171.      If we have just tried the alternatives the second time,
  3172.      return operands to normal and drop through.  */
  3173.  
  3174.   if (commutative >= 0)
  3175.     {
  3176.       swapped = !swapped;
  3177.       if (swapped)
  3178.     {
  3179.       register enum reg_class tclass;
  3180.       register int t;
  3181.  
  3182.       recog_operand[commutative] = substed_operand[commutative + 1];
  3183.       recog_operand[commutative + 1] = substed_operand[commutative];
  3184.  
  3185.       tclass = preferred_class[commutative];
  3186.       preferred_class[commutative] = preferred_class[commutative + 1];
  3187.       preferred_class[commutative + 1] = tclass;
  3188.  
  3189.       t = pref_or_nothing[commutative];
  3190.       pref_or_nothing[commutative] = pref_or_nothing[commutative + 1];
  3191.       pref_or_nothing[commutative + 1] = t;
  3192.  
  3193.       bcopy ((char *) constraints1, (char *) constraints,
  3194.          noperands * sizeof (char *));
  3195.       goto try_swapped;
  3196.     }
  3197.       else
  3198.     {
  3199.       recog_operand[commutative] = substed_operand[commutative];
  3200.       recog_operand[commutative + 1] = substed_operand[commutative + 1];
  3201.     }
  3202.     }
  3203.  
  3204.   /* The operands don't meet the constraints.
  3205.      goal_alternative describes the alternative
  3206.      that we could reach by reloading the fewest operands.
  3207.      Reload so as to fit it.  */
  3208.  
  3209.   if (best == MAX_RECOG_OPERANDS + 300)
  3210.     {
  3211.       /* No alternative works with reloads??  */
  3212.       if (insn_code_number >= 0)
  3213.     abort ();
  3214.       error_for_asm (insn, "inconsistent operand constraints in an `asm'");
  3215.       /* Avoid further trouble with this insn.  */
  3216.       PATTERN (insn) = gen_rtx (USE, VOIDmode, const0_rtx);
  3217.       n_reloads = 0;
  3218.       return;
  3219.     }
  3220.  
  3221.   /* Jump to `finish' from above if all operands are valid already.
  3222.      In that case, goal_alternative_win is all 1.  */
  3223.  finish:
  3224.  
  3225.   /* Right now, for any pair of operands I and J that are required to match,
  3226.      with I < J,
  3227.      goal_alternative_matches[J] is I.
  3228.      Set up goal_alternative_matched as the inverse function:
  3229.      goal_alternative_matched[I] = J.  */
  3230.  
  3231.   for (i = 0; i < noperands; i++)
  3232.     goal_alternative_matched[i] = -1;
  3233.  
  3234.   for (i = 0; i < noperands; i++)
  3235.     if (! goal_alternative_win[i]
  3236.     && goal_alternative_matches[i] >= 0)
  3237.       goal_alternative_matched[goal_alternative_matches[i]] = i;
  3238.  
  3239.   /* If the best alternative is with operands 1 and 2 swapped,
  3240.      consider them swapped before reporting the reloads.  Update the
  3241.      operand numbers of any reloads already pushed.  */
  3242.  
  3243.   if (goal_alternative_swapped)
  3244.     {
  3245.       register rtx tem;
  3246.  
  3247.       tem = substed_operand[commutative];
  3248.       substed_operand[commutative] = substed_operand[commutative + 1];
  3249.       substed_operand[commutative + 1] = tem;
  3250.       tem = recog_operand[commutative];
  3251.       recog_operand[commutative] = recog_operand[commutative + 1];
  3252.       recog_operand[commutative + 1] = tem;
  3253.  
  3254.       for (i = 0; i < n_reloads; i++)
  3255.     {
  3256.       if (reload_opnum[i] == commutative)
  3257.         reload_opnum[i] = commutative + 1;
  3258.       else if (reload_opnum[i] == commutative + 1)
  3259.         reload_opnum[i] = commutative;
  3260.     }
  3261.     }
  3262.  
  3263.   /* Perform whatever substitutions on the operands we are supposed
  3264.      to make due to commutativity or replacement of registers
  3265.      with equivalent constants or memory slots.  */
  3266.  
  3267.   for (i = 0; i < noperands; i++)
  3268.     {
  3269.       *recog_operand_loc[i] = substed_operand[i];
  3270.       /* While we are looping on operands, initialize this.  */
  3271.       operand_reloadnum[i] = -1;
  3272.  
  3273.       /* If this is an earlyclobber operand, we need to widen the scope.
  3274.      The reload must remain valid from the start of the insn being
  3275.      reloaded until after the operand is stored into its destination.
  3276.      We approximate this with RELOAD_OTHER even though we know that we
  3277.      do not conflict with RELOAD_FOR_INPUT_ADDRESS reloads.
  3278.  
  3279.      One special case that is worth checking is when we have an
  3280.      output that is earlyclobber but isn't used past the insn (typically
  3281.      a SCRATCH).  In this case, we only need have the reload live 
  3282.      through the insn itself, but not for any of our input or output
  3283.      reloads. 
  3284.  
  3285.      In any case, anything needed to address this operand can remain
  3286.      however they were previously categorized.  */
  3287.  
  3288.       if (goal_alternative_earlyclobber[i])
  3289.     operand_type[i]
  3290.       = (find_reg_note (insn, REG_UNUSED, recog_operand[i])
  3291.          ? RELOAD_FOR_INSN : RELOAD_OTHER);
  3292.     }
  3293.  
  3294.   /* Any constants that aren't allowed and can't be reloaded
  3295.      into registers are here changed into memory references.  */
  3296.   for (i = 0; i < noperands; i++)
  3297.     if (! goal_alternative_win[i]
  3298.     && CONSTANT_P (recog_operand[i])
  3299.     /* force_const_mem does not accept HIGH.  */
  3300.     && GET_CODE (recog_operand[i]) != HIGH
  3301.     && (PREFERRED_RELOAD_CLASS (recog_operand[i],
  3302.                     (enum reg_class) goal_alternative[i])
  3303.         == NO_REGS)
  3304.     && operand_mode[i] != VOIDmode)
  3305.       {
  3306.     *recog_operand_loc[i] = recog_operand[i]
  3307.       = find_reloads_toplev (force_const_mem (operand_mode[i],
  3308.                           recog_operand[i]),
  3309.                  i, address_type[i], ind_levels, 0);
  3310.     if (alternative_allows_memconst (constraints1[i],
  3311.                      goal_alternative_number))
  3312.       goal_alternative_win[i] = 1;
  3313.       }
  3314.  
  3315.   /* Record the values of the earlyclobber operands for the caller.  */
  3316.   if (goal_earlyclobber)
  3317.     for (i = 0; i < noperands; i++)
  3318.       if (goal_alternative_earlyclobber[i])
  3319.     reload_earlyclobbers[n_earlyclobbers++] = recog_operand[i];
  3320.  
  3321.   /* Now record reloads for all the operands that need them.  */
  3322.   for (i = 0; i < noperands; i++)
  3323.     if (! goal_alternative_win[i])
  3324.       {
  3325.     /* Operands that match previous ones have already been handled.  */
  3326.     if (goal_alternative_matches[i] >= 0)
  3327.       ;
  3328.     /* Handle an operand with a nonoffsettable address
  3329.        appearing where an offsettable address will do
  3330.        by reloading the address into a base register.
  3331.  
  3332.        ??? We can also do this when the operand is a register and
  3333.        reg_equiv_mem is not offsettable, but this is a bit tricky,
  3334.        so we don't bother with it.  It may not be worth doing.  */
  3335.     else if (goal_alternative_matched[i] == -1
  3336.          && goal_alternative_offmemok[i]
  3337.          && GET_CODE (recog_operand[i]) == MEM)
  3338.       {
  3339.         operand_reloadnum[i]
  3340.           = push_reload (XEXP (recog_operand[i], 0), NULL_RTX,
  3341.                  &XEXP (recog_operand[i], 0), NULL_PTR,
  3342.                  BASE_REG_CLASS, GET_MODE (XEXP (recog_operand[i], 0)),
  3343.                  VOIDmode, 0, 0, i, RELOAD_FOR_INPUT);
  3344.         reload_inc[operand_reloadnum[i]]
  3345.           = GET_MODE_SIZE (GET_MODE (recog_operand[i]));
  3346.  
  3347.         /* If this operand is an output, we will have made any
  3348.            reloads for its address as RELOAD_FOR_OUTPUT_ADDRESS, but
  3349.            now we are treating part of the operand as an input, so
  3350.            we must change these to RELOAD_FOR_INPUT_ADDRESS.  */
  3351.  
  3352.         if (modified[i] == RELOAD_WRITE)
  3353.           for (j = 0; j < n_reloads; j++)
  3354.         if (reload_opnum[j] == i
  3355.             && reload_when_needed[j] == RELOAD_FOR_OUTPUT_ADDRESS)
  3356.           reload_when_needed[j] = RELOAD_FOR_INPUT_ADDRESS;
  3357.       }
  3358.     else if (goal_alternative_matched[i] == -1)
  3359.       operand_reloadnum[i] =
  3360.         push_reload (modified[i] != RELOAD_WRITE ? recog_operand[i] : 0,
  3361.              modified[i] != RELOAD_READ ? recog_operand[i] : 0,
  3362.              (modified[i] != RELOAD_WRITE ?
  3363.               recog_operand_loc[i] : 0),
  3364.              modified[i] != RELOAD_READ ? recog_operand_loc[i] : 0,
  3365.              (enum reg_class) goal_alternative[i],
  3366.              (modified[i] == RELOAD_WRITE
  3367.               ? VOIDmode : operand_mode[i]),
  3368.              (modified[i] == RELOAD_READ
  3369.               ? VOIDmode : operand_mode[i]),
  3370.              (insn_code_number < 0 ? 0
  3371.               : insn_operand_strict_low[insn_code_number][i]),
  3372.              0, i, operand_type[i]);
  3373.     /* In a matching pair of operands, one must be input only
  3374.        and the other must be output only.
  3375.        Pass the input operand as IN and the other as OUT.  */
  3376.     else if (modified[i] == RELOAD_READ
  3377.          && modified[goal_alternative_matched[i]] == RELOAD_WRITE)
  3378.       {
  3379.         operand_reloadnum[i]
  3380.           = push_reload (recog_operand[i],
  3381.                  recog_operand[goal_alternative_matched[i]],
  3382.                  recog_operand_loc[i],
  3383.                  recog_operand_loc[goal_alternative_matched[i]],
  3384.                  (enum reg_class) goal_alternative[i],
  3385.                  operand_mode[i],
  3386.                  operand_mode[goal_alternative_matched[i]],
  3387.                  0, 0, i, RELOAD_OTHER);
  3388.         operand_reloadnum[goal_alternative_matched[i]] = output_reloadnum;
  3389.       }
  3390.     else if (modified[i] == RELOAD_WRITE
  3391.          && modified[goal_alternative_matched[i]] == RELOAD_READ)
  3392.       {
  3393.         operand_reloadnum[goal_alternative_matched[i]]
  3394.           = push_reload (recog_operand[goal_alternative_matched[i]],
  3395.                  recog_operand[i],
  3396.                  recog_operand_loc[goal_alternative_matched[i]],
  3397.                  recog_operand_loc[i],
  3398.                  (enum reg_class) goal_alternative[i],
  3399.                  operand_mode[goal_alternative_matched[i]],
  3400.                  operand_mode[i],
  3401.                  0, 0, i, RELOAD_OTHER);
  3402.         operand_reloadnum[i] = output_reloadnum;
  3403.       }
  3404.     else if (insn_code_number >= 0)
  3405.       abort ();
  3406.     else
  3407.       {
  3408.         error_for_asm (insn, "inconsistent operand constraints in an `asm'");
  3409.         /* Avoid further trouble with this insn.  */
  3410.         PATTERN (insn) = gen_rtx (USE, VOIDmode, const0_rtx);
  3411.         n_reloads = 0;
  3412.         return;
  3413.       }
  3414.       }
  3415.     else if (goal_alternative_matched[i] < 0
  3416.          && goal_alternative_matches[i] < 0
  3417.          && optimize)
  3418.       {
  3419.     /* For each non-matching operand that's a MEM or a pseudo-register 
  3420.        that didn't get a hard register, make an optional reload.
  3421.        This may get done even if the insn needs no reloads otherwise.  */
  3422.  
  3423.     rtx operand = recog_operand[i];
  3424.  
  3425.     while (GET_CODE (operand) == SUBREG)
  3426.       operand = XEXP (operand, 0);
  3427.     if ((GET_CODE (operand) == MEM
  3428.          || (GET_CODE (operand) == REG
  3429.          && REGNO (operand) >= FIRST_PSEUDO_REGISTER))
  3430.         && (enum reg_class) goal_alternative[i] != NO_REGS
  3431.         && ! no_input_reloads
  3432.         /* Optional output reloads don't do anything and we mustn't
  3433.            make in-out reloads on insns that are not permitted output
  3434.            reloads.  */
  3435.         && (modified[i] == RELOAD_READ
  3436.         || (modified[i] == RELOAD_READ_WRITE && ! no_output_reloads)))
  3437.       operand_reloadnum[i]
  3438.         = push_reload (modified[i] != RELOAD_WRITE ? recog_operand[i] : 0,
  3439.                modified[i] != RELOAD_READ ? recog_operand[i] : 0,
  3440.                (modified[i] != RELOAD_WRITE
  3441.                 ? recog_operand_loc[i] : 0),
  3442.                (modified[i] != RELOAD_READ
  3443.                 ? recog_operand_loc[i] : 0),
  3444.                (enum reg_class) goal_alternative[i],
  3445.                (modified[i] == RELOAD_WRITE
  3446.                 ? VOIDmode : operand_mode[i]),
  3447.                (modified[i] == RELOAD_READ
  3448.                 ? VOIDmode : operand_mode[i]),
  3449.                (insn_code_number < 0 ? 0
  3450.                 : insn_operand_strict_low[insn_code_number][i]),
  3451.                1, i, operand_type[i]);
  3452.       }
  3453.     else if (goal_alternative_matches[i] >= 0
  3454.          && goal_alternative_win[goal_alternative_matches[i]]
  3455.          && modified[i] == RELOAD_READ
  3456.          && modified[goal_alternative_matches[i]] == RELOAD_WRITE
  3457.          && ! no_input_reloads && ! no_output_reloads
  3458.          && optimize)
  3459.       {
  3460.     /* Similarly, make an optional reload for a pair of matching
  3461.        objects that are in MEM or a pseudo that didn't get a hard reg.  */
  3462.  
  3463.     rtx operand = recog_operand[i];
  3464.  
  3465.     while (GET_CODE (operand) == SUBREG)
  3466.       operand = XEXP (operand, 0);
  3467.     if ((GET_CODE (operand) == MEM
  3468.          || (GET_CODE (operand) == REG
  3469.          && REGNO (operand) >= FIRST_PSEUDO_REGISTER))
  3470.         && ((enum reg_class) goal_alternative[goal_alternative_matches[i]]
  3471.         != NO_REGS))
  3472.       operand_reloadnum[i] = operand_reloadnum[goal_alternative_matches[i]]
  3473.         = push_reload (recog_operand[goal_alternative_matches[i]],
  3474.                recog_operand[i],
  3475.                recog_operand_loc[goal_alternative_matches[i]],
  3476.                recog_operand_loc[i],
  3477.                (enum reg_class) goal_alternative[goal_alternative_matches[i]],
  3478.                operand_mode[goal_alternative_matches[i]],
  3479.                operand_mode[i],
  3480.                0, 1, goal_alternative_matches[i], RELOAD_OTHER);
  3481.       }
  3482.   
  3483.   /* If this insn pattern contains any MATCH_DUP's, make sure that
  3484.      they will be substituted if the operands they match are substituted.
  3485.      Also do now any substitutions we already did on the operands.
  3486.  
  3487.      Don't do this if we aren't making replacements because we might be
  3488.      propagating things allocated by frame pointer elimination into places
  3489.      it doesn't expect.  */
  3490.  
  3491.   if (insn_code_number >= 0 && replace)
  3492.     for (i = insn_n_dups[insn_code_number] - 1; i >= 0; i--)
  3493.       {
  3494.     int opno = recog_dup_num[i];
  3495.     *recog_dup_loc[i] = *recog_operand_loc[opno];
  3496.     if (operand_reloadnum[opno] >= 0)
  3497.       push_replacement (recog_dup_loc[i], operand_reloadnum[opno],
  3498.                 insn_operand_mode[insn_code_number][opno]);
  3499.       }
  3500.  
  3501. #if 0
  3502.   /* This loses because reloading of prior insns can invalidate the equivalence
  3503.      (or at least find_equiv_reg isn't smart enough to find it any more),
  3504.      causing this insn to need more reload regs than it needed before.
  3505.      It may be too late to make the reload regs available.
  3506.      Now this optimization is done safely in choose_reload_regs.  */
  3507.  
  3508.   /* For each reload of a reg into some other class of reg,
  3509.      search for an existing equivalent reg (same value now) in the right class.
  3510.      We can use it as long as we don't need to change its contents.  */
  3511.   for (i = 0; i < n_reloads; i++)
  3512.     if (reload_reg_rtx[i] == 0
  3513.     && reload_in[i] != 0
  3514.     && GET_CODE (reload_in[i]) == REG
  3515.     && reload_out[i] == 0)
  3516.       {
  3517.     reload_reg_rtx[i]
  3518.       = find_equiv_reg (reload_in[i], insn, reload_reg_class[i], -1,
  3519.                 static_reload_reg_p, 0, reload_inmode[i]);
  3520.     /* Prevent generation of insn to load the value
  3521.        because the one we found already has the value.  */
  3522.     if (reload_reg_rtx[i])
  3523.       reload_in[i] = reload_reg_rtx[i];
  3524.       }
  3525. #endif
  3526.  
  3527.   /* Perhaps an output reload can be combined with another
  3528.      to reduce needs by one.  */
  3529.   if (!goal_earlyclobber)
  3530.     combine_reloads ();
  3531.  
  3532.   /* If we have a pair of reloads for parts of an address, they are reloading
  3533.      the same object, the operands themselves were not reloaded, and they
  3534.      are for two operands that are supposed to match, merge the reloads and
  3535.      change the type of the surviving reload to RELOAD_FOR_OPERAND_ADDRESS. */
  3536.  
  3537.   for (i = 0; i < n_reloads; i++)
  3538.     {
  3539.       int k;
  3540.  
  3541.       for (j = i + 1; j < n_reloads; j++)
  3542.     if ((reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS
  3543.          || reload_when_needed[i] == RELOAD_FOR_OUTPUT_ADDRESS)
  3544.         && (reload_when_needed[j] == RELOAD_FOR_INPUT_ADDRESS
  3545.         || reload_when_needed[j] == RELOAD_FOR_OUTPUT_ADDRESS)
  3546.         && rtx_equal_p (reload_in[i], reload_in[j])
  3547.         && (operand_reloadnum[reload_opnum[i]] < 0
  3548.         || reload_optional[operand_reloadnum[reload_opnum[i]]])
  3549.         && (operand_reloadnum[reload_opnum[j]] < 0
  3550.         || reload_optional[operand_reloadnum[reload_opnum[j]]])
  3551.         && (goal_alternative_matches[reload_opnum[i]] == reload_opnum[j]
  3552.         || (goal_alternative_matches[reload_opnum[j]]
  3553.             == reload_opnum[i])))
  3554.       {
  3555.         for (k = 0; k < n_replacements; k++)
  3556.           if (replacements[k].what == j)
  3557.         replacements[k].what = i;
  3558.  
  3559.         reload_when_needed[i] = RELOAD_FOR_OPERAND_ADDRESS;
  3560.         reload_in[j] = 0;
  3561.       }
  3562.     }
  3563.  
  3564.   /* Scan all the reloads and update their type. 
  3565.      If a reload is for the address of an operand and we didn't reload
  3566.      that operand, change the type.  Similarly, change the operand number
  3567.      of a reload when two operands match.  If a reload is optional, treat it
  3568.      as though the operand isn't reloaded.
  3569.  
  3570.      ??? This latter case is somewhat odd because if we do the optional
  3571.      reload, it means the object is hanging around.  Thus we need only
  3572.      do the address reload if the optional reload was NOT done.
  3573.  
  3574.      Change secondary reloads to be the address type of their operand, not
  3575.      the normal type.
  3576.  
  3577.      If an operand's reload is now RELOAD_OTHER, change any
  3578.      RELOAD_FOR_INPUT_ADDRESS reloads of that operand to
  3579.      RELOAD_FOR_OTHER_ADDRESS.  */
  3580.  
  3581.   for (i = 0; i < n_reloads; i++)
  3582.     {
  3583.       if (reload_secondary_p[i]
  3584.       && reload_when_needed[i] == operand_type[reload_opnum[i]])
  3585.     reload_when_needed[i] = address_type[reload_opnum[i]];
  3586.  
  3587.       if ((reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS
  3588.        || reload_when_needed[i] == RELOAD_FOR_OUTPUT_ADDRESS)
  3589.       && (operand_reloadnum[reload_opnum[i]] < 0
  3590.           || reload_optional[operand_reloadnum[reload_opnum[i]]]))
  3591.     {
  3592.       /* If we have a secondary reload to go along with this reload,
  3593.          change its type to RELOAD_FOR_OPADDR_ADDR. */
  3594.  
  3595.       if (reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS
  3596.           && reload_secondary_in_reload[i] != -1)
  3597.         {
  3598.           int secondary_in_reload = reload_secondary_in_reload[i];
  3599.  
  3600.           reload_when_needed[secondary_in_reload] = 
  3601.         RELOAD_FOR_OPADDR_ADDR;
  3602.  
  3603.           /* If there's a tertiary reload we have to change it also. */
  3604.           if (secondary_in_reload > 0
  3605.           && reload_secondary_in_reload[secondary_in_reload] != -1)
  3606.         reload_when_needed[reload_secondary_in_reload[secondary_in_reload]] 
  3607.           = RELOAD_FOR_OPADDR_ADDR;
  3608.         }
  3609.  
  3610.       if (reload_when_needed[i] == RELOAD_FOR_OUTPUT_ADDRESS
  3611.           && reload_secondary_out_reload[i] != -1)
  3612.         {
  3613.           int secondary_out_reload = reload_secondary_out_reload[i];
  3614.  
  3615.           reload_when_needed[secondary_out_reload] = 
  3616.         RELOAD_FOR_OPADDR_ADDR;
  3617.  
  3618.           /* If there's a tertiary reload we have to change it also. */
  3619.           if (secondary_out_reload
  3620.           && reload_secondary_out_reload[secondary_out_reload] != -1)
  3621.         reload_when_needed[reload_secondary_out_reload[secondary_out_reload]] 
  3622.           = RELOAD_FOR_OPADDR_ADDR;
  3623.         }
  3624.       reload_when_needed[i] = RELOAD_FOR_OPERAND_ADDRESS;
  3625.     }
  3626.  
  3627.       if (reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS
  3628.       && operand_reloadnum[reload_opnum[i]] >= 0
  3629.       && (reload_when_needed[operand_reloadnum[reload_opnum[i]]] 
  3630.           == RELOAD_OTHER))
  3631.     reload_when_needed[i] = RELOAD_FOR_OTHER_ADDRESS;
  3632.  
  3633.       if (goal_alternative_matches[reload_opnum[i]] >= 0)
  3634.     reload_opnum[i] = goal_alternative_matches[reload_opnum[i]];
  3635.     }
  3636.  
  3637.   /* See if we have any reloads that are now allowed to be merged
  3638.      because we've changed when the reload is needed to
  3639.      RELOAD_FOR_OPERAND_ADDRESS or RELOAD_FOR_OTHER_ADDRESS.  Only
  3640.      check for the most common cases.  */
  3641.  
  3642.   for (i = 0; i < n_reloads; i++)
  3643.     if (reload_in[i] != 0 && reload_out[i] == 0
  3644.     && (reload_when_needed[i] == RELOAD_FOR_OPERAND_ADDRESS
  3645.         || reload_when_needed[i] == RELOAD_FOR_OTHER_ADDRESS))
  3646.       for (j = 0; j < n_reloads; j++)
  3647.     if (i != j && reload_in[j] != 0 && reload_out[j] == 0
  3648.         && reload_when_needed[j] == reload_when_needed[i]
  3649.         && MATCHES (reload_in[i], reload_in[j])
  3650.         && reload_reg_class[i] == reload_reg_class[j]
  3651.         && !reload_nocombine[i] && !reload_nocombine[j]
  3652.         && reload_reg_rtx[i] == reload_reg_rtx[j])
  3653.       {
  3654.         reload_opnum[i] = MIN (reload_opnum[i], reload_opnum[j]);
  3655.         transfer_replacements (i, j);
  3656.         reload_in[j] = 0;
  3657.       }
  3658.  
  3659. #else /* no REGISTER_CONSTRAINTS */
  3660.   int noperands;
  3661.   int insn_code_number;
  3662.   int goal_earlyclobber = 0; /* Always 0, to make combine_reloads happen.  */
  3663.   register int i;
  3664.   rtx body = PATTERN (insn);
  3665.  
  3666.   n_reloads = 0;
  3667.   n_replacements = 0;
  3668.   n_earlyclobbers = 0;
  3669.   replace_reloads = replace;
  3670.   this_insn = insn;
  3671.  
  3672.   /* Find what kind of insn this is.  NOPERANDS gets number of operands.
  3673.      Store the operand values in RECOG_OPERAND and the locations
  3674.      of the words in the insn that point to them in RECOG_OPERAND_LOC.
  3675.      Return if the insn needs no reload processing.  */
  3676.  
  3677.   switch (GET_CODE (body))
  3678.     {
  3679.     case USE:
  3680.     case CLOBBER:
  3681.     case ASM_INPUT:
  3682.     case ADDR_VEC:
  3683.     case ADDR_DIFF_VEC:
  3684.       return;
  3685.  
  3686.     case PARALLEL:
  3687.     case SET:
  3688.       noperands = asm_noperands (body);
  3689.       if (noperands >= 0)
  3690.     {
  3691.       /* This insn is an `asm' with operands.
  3692.          First, find out how many operands, and allocate space.  */
  3693.  
  3694.       insn_code_number = -1;
  3695.       /* ??? This is a bug! ???
  3696.          Give up and delete this insn if it has too many operands.  */
  3697.       if (noperands > MAX_RECOG_OPERANDS)
  3698.         abort ();
  3699.  
  3700.       /* Now get the operand values out of the insn.  */
  3701.  
  3702.       decode_asm_operands (body, recog_operand, recog_operand_loc,
  3703.                    NULL_PTR, NULL_PTR);
  3704.       break;
  3705.     }
  3706.  
  3707.     default:
  3708.       /* Ordinary insn: recognize it, allocate space for operands and
  3709.      constraints, and get them out via insn_extract.  */
  3710.  
  3711.       insn_code_number = recog_memoized (insn);
  3712.       noperands = insn_n_operands[insn_code_number];
  3713.       insn_extract (insn);
  3714.     }
  3715.  
  3716.   if (noperands == 0)
  3717.     return;
  3718.  
  3719.   for (i = 0; i < noperands; i++)
  3720.     {
  3721.       register RTX_CODE code = GET_CODE (recog_operand[i]);
  3722.       int is_set_dest = GET_CODE (body) == SET && (i == 0);
  3723.  
  3724.       if (insn_code_number >= 0)
  3725.     if (insn_operand_address_p[insn_code_number][i])
  3726.       find_reloads_address (VOIDmode, NULL_PTR,
  3727.                 recog_operand[i], recog_operand_loc[i],
  3728.                 i, RELOAD_FOR_INPUT, ind_levels);
  3729.  
  3730.       /* In these cases, we can't tell if the operand is an input
  3731.      or an output, so be conservative.  In practice it won't be
  3732.      problem.  */
  3733.  
  3734.       if (code == MEM)
  3735.     find_reloads_address (GET_MODE (recog_operand[i]),
  3736.                   recog_operand_loc[i],
  3737.                   XEXP (recog_operand[i], 0),
  3738.                   &XEXP (recog_operand[i], 0),
  3739.                   i, RELOAD_OTHER, ind_levels);
  3740.       if (code == SUBREG)
  3741.     recog_operand[i] = *recog_operand_loc[i]
  3742.       = find_reloads_toplev (recog_operand[i], i, RELOAD_OTHER,
  3743.                  ind_levels, is_set_dest);
  3744.       if (code == REG)
  3745.     {
  3746.       register int regno = REGNO (recog_operand[i]);
  3747.       if (reg_equiv_constant[regno] != 0 && !is_set_dest)
  3748.         recog_operand[i] = *recog_operand_loc[i]
  3749.           = reg_equiv_constant[regno];
  3750. #if 0 /* This might screw code in reload1.c to delete prior output-reload
  3751.      that feeds this insn.  */
  3752.       if (reg_equiv_mem[regno] != 0)
  3753.         recog_operand[i] = *recog_operand_loc[i]
  3754.           = reg_equiv_mem[regno];
  3755. #endif
  3756.     }
  3757.     }
  3758.  
  3759.   /* Perhaps an output reload can be combined with another
  3760.      to reduce needs by one.  */
  3761.   if (!goal_earlyclobber)
  3762.     combine_reloads ();
  3763. #endif /* no REGISTER_CONSTRAINTS */
  3764. }
  3765.  
  3766. /* Return 1 if alternative number ALTNUM in constraint-string CONSTRAINT
  3767.    accepts a memory operand with constant address.  */
  3768.  
  3769. static int
  3770. alternative_allows_memconst (constraint, altnum)
  3771.      char *constraint;
  3772.      int altnum;
  3773. {
  3774.   register int c;
  3775.   /* Skip alternatives before the one requested.  */
  3776.   while (altnum > 0)
  3777.     {
  3778.       while (*constraint++ != ',');
  3779.       altnum--;
  3780.     }
  3781.   /* Scan the requested alternative for 'm' or 'o'.
  3782.      If one of them is present, this alternative accepts memory constants.  */
  3783.   while ((c = *constraint++) && c != ',' && c != '#')
  3784.     if (c == 'm' || c == 'o')
  3785.       return 1;
  3786.   return 0;
  3787. }
  3788.  
  3789. /* Scan X for memory references and scan the addresses for reloading.
  3790.    Also checks for references to "constant" regs that we want to eliminate
  3791.    and replaces them with the values they stand for.
  3792.    We may alter X destructively if it contains a reference to such.
  3793.    If X is just a constant reg, we return the equivalent value
  3794.    instead of X.
  3795.  
  3796.    IND_LEVELS says how many levels of indirect addressing this machine
  3797.    supports.
  3798.  
  3799.    OPNUM and TYPE identify the purpose of the reload.
  3800.  
  3801.    IS_SET_DEST is true if X is the destination of a SET, which is not
  3802.    appropriate to be replaced by a constant.  */
  3803.  
  3804. static rtx
  3805. find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest)
  3806.      rtx x;
  3807.      int opnum;
  3808.      enum reload_type type;
  3809.      int ind_levels;
  3810.      int is_set_dest;
  3811. {
  3812.   register RTX_CODE code = GET_CODE (x);
  3813.  
  3814.   register char *fmt = GET_RTX_FORMAT (code);
  3815.   register int i;
  3816.  
  3817.   if (code == REG)
  3818.     {
  3819.       /* This code is duplicated for speed in find_reloads.  */
  3820.       register int regno = REGNO (x);
  3821.       if (reg_equiv_constant[regno] != 0 && !is_set_dest)
  3822.     x = reg_equiv_constant[regno];
  3823. #if 0
  3824. /*  This creates (subreg (mem...)) which would cause an unnecessary
  3825.     reload of the mem.  */
  3826.       else if (reg_equiv_mem[regno] != 0)
  3827.     x = reg_equiv_mem[regno];
  3828. #endif
  3829.       else if (reg_equiv_address[regno] != 0)
  3830.     {
  3831.       /* If reg_equiv_address varies, it may be shared, so copy it.  */
  3832.       rtx addr = reg_equiv_address[regno];
  3833.  
  3834.       if (rtx_varies_p (addr))
  3835.         addr = copy_rtx (addr);
  3836.  
  3837.       x = gen_rtx (MEM, GET_MODE (x), addr);
  3838.       RTX_UNCHANGING_P (x) = RTX_UNCHANGING_P (regno_reg_rtx[regno]);
  3839.       find_reloads_address (GET_MODE (x), NULL_PTR,
  3840.                 XEXP (x, 0),
  3841.                 &XEXP (x, 0), opnum, type, ind_levels);
  3842.     }
  3843.       return x;
  3844.     }
  3845.   if (code == MEM)
  3846.     {
  3847.       rtx tem = x;
  3848.       find_reloads_address (GET_MODE (x), &tem, XEXP (x, 0), &XEXP (x, 0),
  3849.                 opnum, type, ind_levels);
  3850.       return tem;
  3851.     }
  3852.  
  3853.   if (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG)
  3854.     {
  3855.       /* Check for SUBREG containing a REG that's equivalent to a constant. 
  3856.      If the constant has a known value, truncate it right now.
  3857.      Similarly if we are extracting a single-word of a multi-word
  3858.      constant.  If the constant is symbolic, allow it to be substituted
  3859.      normally.  push_reload will strip the subreg later.  If the
  3860.      constant is VOIDmode, abort because we will lose the mode of
  3861.      the register (this should never happen because one of the cases
  3862.      above should handle it).  */
  3863.  
  3864.       register int regno = REGNO (SUBREG_REG (x));
  3865.       rtx tem;
  3866.  
  3867.       if (subreg_lowpart_p (x)
  3868.       && regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0
  3869.       && reg_equiv_constant[regno] != 0
  3870.       && (tem = gen_lowpart_common (GET_MODE (x),
  3871.                     reg_equiv_constant[regno])) != 0)
  3872.     return tem;
  3873.  
  3874.       if (GET_MODE_BITSIZE (GET_MODE (x)) == BITS_PER_WORD
  3875.       && regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0
  3876.       && reg_equiv_constant[regno] != 0
  3877.       && (tem = operand_subword (reg_equiv_constant[regno],
  3878.                      SUBREG_WORD (x), 0,
  3879.                      GET_MODE (SUBREG_REG (x)))) != 0)
  3880.     return tem;
  3881.  
  3882.       if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0
  3883.       && reg_equiv_constant[regno] != 0
  3884.       && GET_MODE (reg_equiv_constant[regno]) == VOIDmode)
  3885.     abort ();
  3886.  
  3887.       /* If the subreg contains a reg that will be converted to a mem,
  3888.      convert the subreg to a narrower memref now.
  3889.      Otherwise, we would get (subreg (mem ...) ...),
  3890.      which would force reload of the mem.
  3891.  
  3892.      We also need to do this if there is an equivalent MEM that is
  3893.      not offsettable.  In that case, alter_subreg would produce an
  3894.      invalid address on big-endian machines.
  3895.  
  3896.      For machines that extend byte loads, we must not reload using
  3897.      a wider mode if we have a paradoxical SUBREG.  find_reloads will
  3898.      force a reload in that case.  So we should not do anything here.  */
  3899.  
  3900.       else if (regno >= FIRST_PSEUDO_REGISTER
  3901. #ifdef LOAD_EXTEND_OP
  3902.            && (GET_MODE_SIZE (GET_MODE (x))
  3903.            <= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
  3904. #endif
  3905.            && (reg_equiv_address[regno] != 0
  3906.            || (reg_equiv_mem[regno] != 0
  3907.                && (! strict_memory_address_p (GET_MODE (x), 
  3908.                               XEXP (reg_equiv_mem[regno], 0))
  3909.                || ! offsettable_memref_p (reg_equiv_mem[regno])))))
  3910.     {
  3911.       int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
  3912.       rtx addr = (reg_equiv_address[regno] ? reg_equiv_address[regno]
  3913.               : XEXP (reg_equiv_mem[regno], 0));
  3914. #if BYTES_BIG_ENDIAN
  3915.       int size;
  3916.       size = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)));
  3917.       offset += MIN (size, UNITS_PER_WORD);
  3918.       size = GET_MODE_SIZE (GET_MODE (x));
  3919.       offset -= MIN (size, UNITS_PER_WORD);
  3920. #endif
  3921.       addr = plus_constant (addr, offset);
  3922.       x = gen_rtx (MEM, GET_MODE (x), addr);
  3923.       RTX_UNCHANGING_P (x) = RTX_UNCHANGING_P (regno_reg_rtx[regno]);
  3924.       find_reloads_address (GET_MODE (x), NULL_PTR,
  3925.                 XEXP (x, 0),
  3926.                 &XEXP (x, 0), opnum, type, ind_levels);
  3927.     }
  3928.  
  3929.     }
  3930.  
  3931.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  3932.     {
  3933.       if (fmt[i] == 'e')
  3934.     XEXP (x, i) = find_reloads_toplev (XEXP (x, i), opnum, type,
  3935.                        ind_levels, is_set_dest);
  3936.     }
  3937.   return x;
  3938. }
  3939.  
  3940. /* Return a mem ref for the memory equivalent of reg REGNO.
  3941.    This mem ref is not shared with anything.  */
  3942.  
  3943. static rtx
  3944. make_memloc (ad, regno)
  3945.      rtx ad;
  3946.      int regno;
  3947. {
  3948.   register int i;
  3949.   rtx tem = reg_equiv_address[regno];
  3950.  
  3951. #if 0 /* We cannot safely reuse a memloc made here;
  3952.      if the pseudo appears twice, and its mem needs a reload,
  3953.      it gets two separate reloads assigned, but it only
  3954.      gets substituted with the second of them;
  3955.      then it can get used before that reload reg gets loaded up.  */
  3956.   for (i = 0; i < n_memlocs; i++)
  3957.     if (rtx_equal_p (tem, XEXP (memlocs[i], 0)))
  3958.       return memlocs[i];
  3959. #endif
  3960.  
  3961.   /* If TEM might contain a pseudo, we must copy it to avoid
  3962.      modifying it when we do the substitution for the reload.  */
  3963.   if (rtx_varies_p (tem))
  3964.     tem = copy_rtx (tem);
  3965.  
  3966.   tem = gen_rtx (MEM, GET_MODE (ad), tem);
  3967.   RTX_UNCHANGING_P (tem) = RTX_UNCHANGING_P (regno_reg_rtx[regno]);
  3968.   memlocs[n_memlocs++] = tem;
  3969.   return tem;
  3970. }
  3971.  
  3972. /* Record all reloads needed for handling memory address AD
  3973.    which appears in *LOC in a memory reference to mode MODE
  3974.    which itself is found in location  *MEMREFLOC.
  3975.    Note that we take shortcuts assuming that no multi-reg machine mode
  3976.    occurs as part of an address.
  3977.  
  3978.    OPNUM and TYPE specify the purpose of this reload.
  3979.  
  3980.    IND_LEVELS says how many levels of indirect addressing this machine
  3981.    supports.
  3982.  
  3983.    Value is nonzero if this address is reloaded or replaced as a whole.
  3984.    This is interesting to the caller if the address is an autoincrement.
  3985.  
  3986.    Note that there is no verification that the address will be valid after
  3987.    this routine does its work.  Instead, we rely on the fact that the address
  3988.    was valid when reload started.  So we need only undo things that reload
  3989.    could have broken.  These are wrong register types, pseudos not allocated
  3990.    to a hard register, and frame pointer elimination.  */
  3991.  
  3992. static int
  3993. find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels)
  3994.      enum machine_mode mode;
  3995.      rtx *memrefloc;
  3996.      rtx ad;
  3997.      rtx *loc;
  3998.      int opnum;
  3999.      enum reload_type type;
  4000.      int ind_levels;
  4001. {
  4002.   register int regno;
  4003.   rtx tem;
  4004.  
  4005.   /* If the address is a register, see if it is a legitimate address and
  4006.      reload if not.  We first handle the cases where we need not reload
  4007.      or where we must reload in a non-standard way.  */
  4008.  
  4009.   if (GET_CODE (ad) == REG)
  4010.     {
  4011.       regno = REGNO (ad);
  4012.  
  4013.       if (reg_equiv_constant[regno] != 0
  4014.       && strict_memory_address_p (mode, reg_equiv_constant[regno]))
  4015.     {
  4016.       *loc = ad = reg_equiv_constant[regno];
  4017.       return 1;
  4018.     }
  4019.  
  4020.       else if (reg_equiv_address[regno] != 0)
  4021.     {
  4022.       tem = make_memloc (ad, regno);
  4023.       find_reloads_address (GET_MODE (tem), NULL_PTR, XEXP (tem, 0),
  4024.                 &XEXP (tem, 0), opnum, type, ind_levels);
  4025.       push_reload (tem, NULL_RTX, loc, NULL_PTR, BASE_REG_CLASS,
  4026.                GET_MODE (ad), VOIDmode, 0, 0,
  4027.                opnum, type);
  4028.       return 1;
  4029.     }
  4030.  
  4031.       /* We can avoid a reload if the register's equivalent memory expression
  4032.      is valid as an indirect memory address.
  4033.      But not all addresses are valid in a mem used as an indirect address:
  4034.      only reg or reg+constant.  */
  4035.  
  4036.       else if (reg_equiv_mem[regno] != 0 && ind_levels > 0
  4037.            && strict_memory_address_p (mode, reg_equiv_mem[regno])
  4038.            && (GET_CODE (XEXP (reg_equiv_mem[regno], 0)) == REG
  4039.            || (GET_CODE (XEXP (reg_equiv_mem[regno], 0)) == PLUS
  4040.                && GET_CODE (XEXP (XEXP (reg_equiv_mem[regno], 0), 0)) == REG
  4041.                && CONSTANT_P (XEXP (XEXP (reg_equiv_mem[regno], 0), 0)))))
  4042.     return 0;
  4043.  
  4044.       /* The only remaining case where we can avoid a reload is if this is a
  4045.      hard register that is valid as a base register and which is not the
  4046.      subject of a CLOBBER in this insn.  */
  4047.  
  4048.       else if (regno < FIRST_PSEUDO_REGISTER && REGNO_OK_FOR_BASE_P (regno)
  4049.            && ! regno_clobbered_p (regno, this_insn))
  4050.     return 0;
  4051.  
  4052.       /* If we do not have one of the cases above, we must do the reload.  */
  4053.       push_reload (ad, NULL_RTX, loc, NULL_PTR, BASE_REG_CLASS,
  4054.            GET_MODE (ad), VOIDmode, 0, 0, opnum, type);
  4055.       return 1;
  4056.     }
  4057.  
  4058.   if (strict_memory_address_p (mode, ad))
  4059.     {
  4060.       /* The address appears valid, so reloads are not needed.
  4061.      But the address may contain an eliminable register.
  4062.      This can happen because a machine with indirect addressing
  4063.      may consider a pseudo register by itself a valid address even when
  4064.      it has failed to get a hard reg.
  4065.      So do a tree-walk to find and eliminate all such regs.  */
  4066.  
  4067.       /* But first quickly dispose of a common case.  */
  4068.       if (GET_CODE (ad) == PLUS
  4069.       && GET_CODE (XEXP (ad, 1)) == CONST_INT
  4070.       && GET_CODE (XEXP (ad, 0)) == REG
  4071.       && reg_equiv_constant[REGNO (XEXP (ad, 0))] == 0)
  4072.     return 0;
  4073.  
  4074.       subst_reg_equivs_changed = 0;
  4075.       *loc = subst_reg_equivs (ad);
  4076.  
  4077.       if (! subst_reg_equivs_changed)
  4078.     return 0;
  4079.  
  4080.       /* Check result for validity after substitution.  */
  4081.       if (strict_memory_address_p (mode, ad))
  4082.     return 0;
  4083.     }
  4084.  
  4085.   /* The address is not valid.  We have to figure out why.  One possibility
  4086.      is that it is itself a MEM.  This can happen when the frame pointer is
  4087.      being eliminated, a pseudo is not allocated to a hard register, and the
  4088.      offset between the frame and stack pointers is not its initial value.
  4089.      In that case the pseudo will have been replaced by a MEM referring to
  4090.      the stack pointer.  */
  4091.   if (GET_CODE (ad) == MEM)
  4092.     {
  4093.       /* First ensure that the address in this MEM is valid.  Then, unless
  4094.      indirect addresses are valid, reload the MEM into a register.  */
  4095.       tem = ad;
  4096.       find_reloads_address (GET_MODE (ad), &tem, XEXP (ad, 0), &XEXP (ad, 0),
  4097.                 opnum, type, ind_levels == 0 ? 0 : ind_levels - 1);
  4098.  
  4099.       /* If tem was changed, then we must create a new memory reference to
  4100.      hold it and store it back into memrefloc.  */
  4101.       if (tem != ad && memrefloc)
  4102.     {
  4103.       *memrefloc = copy_rtx (*memrefloc);
  4104.       copy_replacements (tem, XEXP (*memrefloc, 0));
  4105.       loc = &XEXP (*memrefloc, 0);
  4106.     }
  4107.  
  4108.       /* Check similar cases as for indirect addresses as above except
  4109.      that we can allow pseudos and a MEM since they should have been
  4110.      taken care of above.  */
  4111.  
  4112.       if (ind_levels == 0
  4113.       || (GET_CODE (XEXP (tem, 0)) == SYMBOL_REF && ! indirect_symref_ok)
  4114.       || GET_CODE (XEXP (tem, 0)) == MEM
  4115.       || ! (GET_CODE (XEXP (tem, 0)) == REG
  4116.         || (GET_CODE (XEXP (tem, 0)) == PLUS
  4117.             && GET_CODE (XEXP (XEXP (tem, 0), 0)) == REG
  4118.             && GET_CODE (XEXP (XEXP (tem, 0), 1)) == CONST_INT)))
  4119.     {
  4120.       /* Must use TEM here, not AD, since it is the one that will
  4121.          have any subexpressions reloaded, if needed.  */
  4122.       push_reload (tem, NULL_RTX, loc, NULL_PTR,
  4123.                BASE_REG_CLASS, GET_MODE (tem), VOIDmode, 0,
  4124.                0, opnum, type);
  4125.       return 1;
  4126.     }
  4127.       else
  4128.     return 0;
  4129.     }
  4130.  
  4131.   /* If we have address of a stack slot but it's not valid
  4132.      (displacement is too large), compute the sum in a register.  */
  4133.   else if (GET_CODE (ad) == PLUS
  4134.        && (XEXP (ad, 0) == frame_pointer_rtx
  4135. #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
  4136.            || XEXP (ad, 0) == hard_frame_pointer_rtx
  4137. #endif
  4138. #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
  4139.            || XEXP (ad, 0) == arg_pointer_rtx
  4140. #endif
  4141.            || XEXP (ad, 0) == stack_pointer_rtx)
  4142.        && GET_CODE (XEXP (ad, 1)) == CONST_INT)
  4143.     {
  4144.       /* Unshare the MEM rtx so we can safely alter it.  */
  4145.       if (memrefloc)
  4146.     {
  4147.       *memrefloc = copy_rtx (*memrefloc);
  4148.       loc = &XEXP (*memrefloc, 0);
  4149.     }
  4150.       if (double_reg_address_ok)
  4151.     {
  4152.       /* Unshare the sum as well.  */
  4153.       *loc = ad = copy_rtx (ad);
  4154.       /* Reload the displacement into an index reg.
  4155.          We assume the frame pointer or arg pointer is a base reg.  */
  4156.       find_reloads_address_part (XEXP (ad, 1), &XEXP (ad, 1),
  4157.                      INDEX_REG_CLASS, GET_MODE (ad), opnum,
  4158.                      type, ind_levels);
  4159.     }
  4160.       else
  4161.     {
  4162.       /* If the sum of two regs is not necessarily valid,
  4163.          reload the sum into a base reg.
  4164.          That will at least work.  */
  4165.       find_reloads_address_part (ad, loc, BASE_REG_CLASS, Pmode,
  4166.                      opnum, type, ind_levels);
  4167.     }
  4168.       return 1;
  4169.     }
  4170.  
  4171.   /* If we have an indexed stack slot, there are three possible reasons why
  4172.      it might be invalid: The index might need to be reloaded, the address
  4173.      might have been made by frame pointer elimination and hence have a
  4174.      constant out of range, or both reasons might apply.  
  4175.  
  4176.      We can easily check for an index needing reload, but even if that is the
  4177.      case, we might also have an invalid constant.  To avoid making the
  4178.      conservative assumption and requiring two reloads, we see if this address
  4179.      is valid when not interpreted strictly.  If it is, the only problem is
  4180.      that the index needs a reload and find_reloads_address_1 will take care
  4181.      of it.
  4182.  
  4183.      There is still a case when we might generate an extra reload,
  4184.      however.  In certain cases eliminate_regs will return a MEM for a REG
  4185.      (see the code there for details).  In those cases, memory_address_p
  4186.      applied to our address will return 0 so we will think that our offset
  4187.      must be too large.  But it might indeed be valid and the only problem
  4188.      is that a MEM is present where a REG should be.  This case should be
  4189.      very rare and there doesn't seem to be any way to avoid it.
  4190.  
  4191.      If we decide to do something here, it must be that
  4192.      `double_reg_address_ok' is true and that this address rtl was made by
  4193.      eliminate_regs.  We generate a reload of the fp/sp/ap + constant and
  4194.      rework the sum so that the reload register will be added to the index.
  4195.      This is safe because we know the address isn't shared.
  4196.  
  4197.      We check for fp/ap/sp as both the first and second operand of the
  4198.      innermost PLUS.  */
  4199.  
  4200.   else if (GET_CODE (ad) == PLUS && GET_CODE (XEXP (ad, 1)) == CONST_INT
  4201.        && GET_CODE (XEXP (ad, 0)) == PLUS
  4202.        && (XEXP (XEXP (ad, 0), 0) == frame_pointer_rtx
  4203. #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
  4204.            || XEXP (XEXP (ad, 0), 0) == hard_frame_pointer_rtx
  4205. #endif
  4206. #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
  4207.            || XEXP (XEXP (ad, 0), 0) == arg_pointer_rtx
  4208. #endif
  4209.            || XEXP (XEXP (ad, 0), 0) == stack_pointer_rtx)
  4210.        && ! memory_address_p (mode, ad))
  4211.     {
  4212.       *loc = ad = gen_rtx (PLUS, GET_MODE (ad),
  4213.                plus_constant (XEXP (XEXP (ad, 0), 0),
  4214.                       INTVAL (XEXP (ad, 1))),
  4215.                XEXP (XEXP (ad, 0), 1));
  4216.       find_reloads_address_part (XEXP (ad, 0), &XEXP (ad, 0), BASE_REG_CLASS,
  4217.                  GET_MODE (ad), opnum, type, ind_levels);
  4218.       find_reloads_address_1 (XEXP (ad, 1), 1, &XEXP (ad, 1), opnum, type, 0);
  4219.  
  4220.       return 1;
  4221.     }
  4222.                
  4223.   else if (GET_CODE (ad) == PLUS && GET_CODE (XEXP (ad, 1)) == CONST_INT
  4224.        && GET_CODE (XEXP (ad, 0)) == PLUS
  4225.        && (XEXP (XEXP (ad, 0), 1) == frame_pointer_rtx
  4226. #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
  4227.            || XEXP (XEXP (ad, 0), 1) == hard_frame_pointer_rtx
  4228. #endif
  4229. #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
  4230.            || XEXP (XEXP (ad, 0), 1) == arg_pointer_rtx
  4231. #endif
  4232.            || XEXP (XEXP (ad, 0), 1) == stack_pointer_rtx)
  4233.        && ! memory_address_p (mode, ad))
  4234.     {
  4235.       *loc = ad = gen_rtx (PLUS, GET_MODE (ad),
  4236.                plus_constant (XEXP (XEXP (ad, 0), 1),
  4237.                       INTVAL (XEXP (ad, 1))),
  4238.                XEXP (XEXP (ad, 0), 0));
  4239.       find_reloads_address_part (XEXP (ad, 0), &XEXP (ad, 0), BASE_REG_CLASS,
  4240.                  GET_MODE (ad), opnum, type, ind_levels);
  4241.       find_reloads_address_1 (XEXP (ad, 1), 1, &XEXP (ad, 1), opnum, type, 0);
  4242.  
  4243.       return 1;
  4244.     }
  4245.                
  4246.   /* See if address becomes valid when an eliminable register
  4247.      in a sum is replaced.  */
  4248.  
  4249.   tem = ad;
  4250.   if (GET_CODE (ad) == PLUS)
  4251.     tem = subst_indexed_address (ad);
  4252.   if (tem != ad && strict_memory_address_p (mode, tem))
  4253.     {
  4254.       /* Ok, we win that way.  Replace any additional eliminable
  4255.      registers.  */
  4256.  
  4257.       subst_reg_equivs_changed = 0;
  4258.       tem = subst_reg_equivs (tem);
  4259.  
  4260.       /* Make sure that didn't make the address invalid again.  */
  4261.  
  4262.       if (! subst_reg_equivs_changed || strict_memory_address_p (mode, tem))
  4263.     {
  4264.       *loc = tem;
  4265.       return 0;
  4266.     }
  4267.     }
  4268.  
  4269.   /* If constants aren't valid addresses, reload the constant address
  4270.      into a register.  */
  4271.   if (CONSTANT_P (ad) && ! strict_memory_address_p (mode, ad))
  4272.     {
  4273.       /* If AD is in address in the constant pool, the MEM rtx may be shared.
  4274.      Unshare it so we can safely alter it.  */
  4275.       if (memrefloc && GET_CODE (ad) == SYMBOL_REF
  4276.       && CONSTANT_POOL_ADDRESS_P (ad))
  4277.     {
  4278.       *memrefloc = copy_rtx (*memrefloc);
  4279.       loc = &XEXP (*memrefloc, 0);
  4280.     }
  4281.  
  4282.       find_reloads_address_part (ad, loc, BASE_REG_CLASS, Pmode, opnum, type,
  4283.                  ind_levels);
  4284.       return 1;
  4285.     }
  4286.  
  4287.   return find_reloads_address_1 (ad, 0, loc, opnum, type, ind_levels);
  4288. }
  4289.  
  4290. /* Find all pseudo regs appearing in AD
  4291.    that are eliminable in favor of equivalent values
  4292.    and do not have hard regs; replace them by their equivalents.  */
  4293.  
  4294. static rtx
  4295. subst_reg_equivs (ad)
  4296.      rtx ad;
  4297. {
  4298.   register RTX_CODE code = GET_CODE (ad);
  4299.   register int i;
  4300.   register char *fmt;
  4301.  
  4302.   switch (code)
  4303.     {
  4304.     case HIGH:
  4305.     case CONST_INT:
  4306.     case CONST:
  4307.     case CONST_DOUBLE:
  4308.     case SYMBOL_REF:
  4309.     case LABEL_REF:
  4310.     case PC:
  4311.     case CC0:
  4312.       return ad;
  4313.  
  4314.     case REG:
  4315.       {
  4316.     register int regno = REGNO (ad);
  4317.  
  4318.     if (reg_equiv_constant[regno] != 0)
  4319.       {
  4320.         subst_reg_equivs_changed = 1;
  4321.         return reg_equiv_constant[regno];
  4322.       }
  4323.       }
  4324.       return ad;
  4325.  
  4326.     case PLUS:
  4327.       /* Quickly dispose of a common case.  */
  4328.       if (XEXP (ad, 0) == frame_pointer_rtx
  4329.       && GET_CODE (XEXP (ad, 1)) == CONST_INT)
  4330.     return ad;
  4331.     }
  4332.  
  4333.   fmt = GET_RTX_FORMAT (code);
  4334.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  4335.     if (fmt[i] == 'e')
  4336.       XEXP (ad, i) = subst_reg_equivs (XEXP (ad, i));
  4337.   return ad;
  4338. }
  4339.  
  4340. /* Compute the sum of X and Y, making canonicalizations assumed in an
  4341.    address, namely: sum constant integers, surround the sum of two
  4342.    constants with a CONST, put the constant as the second operand, and
  4343.    group the constant on the outermost sum.
  4344.  
  4345.    This routine assumes both inputs are already in canonical form.  */
  4346.  
  4347. rtx
  4348. form_sum (x, y)
  4349.      rtx x, y;
  4350. {
  4351.   rtx tem;
  4352.   enum machine_mode mode = GET_MODE (x);
  4353.  
  4354.   if (mode == VOIDmode)
  4355.     mode = GET_MODE (y);
  4356.  
  4357.   if (mode == VOIDmode)
  4358.     mode = Pmode;
  4359.  
  4360.   if (GET_CODE (x) == CONST_INT)
  4361.     return plus_constant (y, INTVAL (x));
  4362.   else if (GET_CODE (y) == CONST_INT)
  4363.     return plus_constant (x, INTVAL (y));
  4364.   else if (CONSTANT_P (x))
  4365.     tem = x, x = y, y = tem;
  4366.  
  4367.   if (GET_CODE (x) == PLUS && CONSTANT_P (XEXP (x, 1)))
  4368.     return form_sum (XEXP (x, 0), form_sum (XEXP (x, 1), y));
  4369.  
  4370.   /* Note that if the operands of Y are specified in the opposite
  4371.      order in the recursive calls below, infinite recursion will occur.  */
  4372.   if (GET_CODE (y) == PLUS && CONSTANT_P (XEXP (y, 1)))
  4373.     return form_sum (form_sum (x, XEXP (y, 0)), XEXP (y, 1));
  4374.  
  4375.   /* If both constant, encapsulate sum.  Otherwise, just form sum.  A
  4376.      constant will have been placed second.  */
  4377.   if (CONSTANT_P (x) && CONSTANT_P (y))
  4378.     {
  4379.       if (GET_CODE (x) == CONST)
  4380.     x = XEXP (x, 0);
  4381.       if (GET_CODE (y) == CONST)
  4382.     y = XEXP (y, 0);
  4383.  
  4384.       return gen_rtx (CONST, VOIDmode, gen_rtx (PLUS, mode, x, y));
  4385.     }
  4386.  
  4387.   return gen_rtx (PLUS, mode, x, y);
  4388. }
  4389.  
  4390. /* If ADDR is a sum containing a pseudo register that should be
  4391.    replaced with a constant (from reg_equiv_constant),
  4392.    return the result of doing so, and also apply the associative
  4393.    law so that the result is more likely to be a valid address.
  4394.    (But it is not guaranteed to be one.)
  4395.  
  4396.    Note that at most one register is replaced, even if more are
  4397.    replaceable.  Also, we try to put the result into a canonical form
  4398.    so it is more likely to be a valid address.
  4399.  
  4400.    In all other cases, return ADDR.  */
  4401.  
  4402. static rtx
  4403. subst_indexed_address (addr)
  4404.      rtx addr;
  4405. {
  4406.   rtx op0 = 0, op1 = 0, op2 = 0;
  4407.   rtx tem;
  4408.   int regno;
  4409.  
  4410.   if (GET_CODE (addr) == PLUS)
  4411.     {
  4412.       /* Try to find a register to replace.  */
  4413.       op0 = XEXP (addr, 0), op1 = XEXP (addr, 1), op2 = 0;
  4414.       if (GET_CODE (op0) == REG
  4415.       && (regno = REGNO (op0)) >= FIRST_PSEUDO_REGISTER
  4416.       && reg_renumber[regno] < 0
  4417.       && reg_equiv_constant[regno] != 0)
  4418.     op0 = reg_equiv_constant[regno];
  4419.       else if (GET_CODE (op1) == REG
  4420.       && (regno = REGNO (op1)) >= FIRST_PSEUDO_REGISTER
  4421.       && reg_renumber[regno] < 0
  4422.       && reg_equiv_constant[regno] != 0)
  4423.     op1 = reg_equiv_constant[regno];
  4424.       else if (GET_CODE (op0) == PLUS
  4425.            && (tem = subst_indexed_address (op0)) != op0)
  4426.     op0 = tem;
  4427.       else if (GET_CODE (op1) == PLUS
  4428.            && (tem = subst_indexed_address (op1)) != op1)
  4429.     op1 = tem;
  4430.       else
  4431.     return addr;
  4432.  
  4433.       /* Pick out up to three things to add.  */
  4434.       if (GET_CODE (op1) == PLUS)
  4435.     op2 = XEXP (op1, 1), op1 = XEXP (op1, 0);
  4436.       else if (GET_CODE (op0) == PLUS)
  4437.     op2 = op1, op1 = XEXP (op0, 1), op0 = XEXP (op0, 0);
  4438.  
  4439.       /* Compute the sum.  */
  4440.       if (op2 != 0)
  4441.     op1 = form_sum (op1, op2);
  4442.       if (op1 != 0)
  4443.     op0 = form_sum (op0, op1);
  4444.  
  4445.       return op0;
  4446.     }
  4447.   return addr;
  4448. }
  4449.  
  4450. /* Record the pseudo registers we must reload into hard registers
  4451.    in a subexpression of a would-be memory address, X.
  4452.    (This function is not called if the address we find is strictly valid.)
  4453.    CONTEXT = 1 means we are considering regs as index regs,
  4454.    = 0 means we are considering them as base regs.
  4455.  
  4456.    OPNUM and TYPE specify the purpose of any reloads made.
  4457.  
  4458.    IND_LEVELS says how many levels of indirect addressing are
  4459.    supported at this point in the address.
  4460.  
  4461.    We return nonzero if X, as a whole, is reloaded or replaced.  */
  4462.  
  4463. /* Note that we take shortcuts assuming that no multi-reg machine mode
  4464.    occurs as part of an address.
  4465.    Also, this is not fully machine-customizable; it works for machines
  4466.    such as vaxes and 68000's and 32000's, but other possible machines
  4467.    could have addressing modes that this does not handle right.  */
  4468.  
  4469. static int
  4470. find_reloads_address_1 (x, context, loc, opnum, type, ind_levels)
  4471.      rtx x;
  4472.      int context;
  4473.      rtx *loc;
  4474.      int opnum;
  4475.      enum reload_type type;
  4476.      int ind_levels;
  4477. {
  4478.   register RTX_CODE code = GET_CODE (x);
  4479.  
  4480.   switch (code)
  4481.     {
  4482.     case PLUS:
  4483.       {
  4484.     register rtx orig_op0 = XEXP (x, 0);
  4485.     register rtx orig_op1 = XEXP (x, 1);
  4486.     register RTX_CODE code0 = GET_CODE (orig_op0);
  4487.     register RTX_CODE code1 = GET_CODE (orig_op1);
  4488.     register rtx op0 = orig_op0;
  4489.     register rtx op1 = orig_op1;
  4490.  
  4491.     if (GET_CODE (op0) == SUBREG)
  4492.       {
  4493.         op0 = SUBREG_REG (op0);
  4494.         code0 = GET_CODE (op0);
  4495.       }
  4496.  
  4497.     if (GET_CODE (op1) == SUBREG)
  4498.       {
  4499.         op1 = SUBREG_REG (op1);
  4500.         code1 = GET_CODE (op1);
  4501.       }
  4502.  
  4503.     if (code0 == MULT || code0 == SIGN_EXTEND || code1 == MEM)
  4504.       {
  4505.         find_reloads_address_1 (orig_op0, 1, &XEXP (x, 0), opnum, type,
  4506.                     ind_levels);
  4507.         find_reloads_address_1 (orig_op1, 0, &XEXP (x, 1), opnum, type,
  4508.                     ind_levels);
  4509.       }
  4510.  
  4511.     else if (code1 == MULT || code1 == SIGN_EXTEND || code0 == MEM)
  4512.       {
  4513.         find_reloads_address_1 (orig_op0, 0, &XEXP (x, 0), opnum, type,
  4514.                     ind_levels);
  4515.         find_reloads_address_1 (orig_op1, 1, &XEXP (x, 1), opnum, type,
  4516.                     ind_levels);
  4517.       }
  4518.  
  4519.     else if (code0 == CONST_INT || code0 == CONST
  4520.          || code0 == SYMBOL_REF || code0 == LABEL_REF)
  4521.       find_reloads_address_1 (orig_op1, 0, &XEXP (x, 1), opnum, type,
  4522.                   ind_levels);
  4523.  
  4524.     else if (code1 == CONST_INT || code1 == CONST
  4525.          || code1 == SYMBOL_REF || code1 == LABEL_REF)
  4526.       find_reloads_address_1 (orig_op0, 0, &XEXP (x, 0), opnum, type,
  4527.                   ind_levels);
  4528.  
  4529.     else if (code0 == REG && code1 == REG)
  4530.       {
  4531.         if (REG_OK_FOR_INDEX_P (op0)
  4532.         && REG_OK_FOR_BASE_P (op1))
  4533.           return 0;
  4534.         else if (REG_OK_FOR_INDEX_P (op1)
  4535.              && REG_OK_FOR_BASE_P (op0))
  4536.           return 0;
  4537.         else if (REG_OK_FOR_BASE_P (op1))
  4538.           find_reloads_address_1 (orig_op0, 1, &XEXP (x, 0), opnum, type, 
  4539.                       ind_levels);
  4540.         else if (REG_OK_FOR_BASE_P (op0))
  4541.           find_reloads_address_1 (orig_op1, 1, &XEXP (x, 1), opnum, type,
  4542.                       ind_levels);
  4543.         else if (REG_OK_FOR_INDEX_P (op1))
  4544.           find_reloads_address_1 (orig_op0, 0, &XEXP (x, 0), opnum, type,
  4545.                       ind_levels);
  4546.         else if (REG_OK_FOR_INDEX_P (op0))
  4547.         find_reloads_address_1 (orig_op1, 0, &XEXP (x, 1), opnum, type,
  4548.                     ind_levels);
  4549.         else
  4550.           {
  4551.         find_reloads_address_1 (orig_op0, 1, &XEXP (x, 0), opnum, type,
  4552.                     ind_levels);
  4553.         find_reloads_address_1 (orig_op1, 0, &XEXP (x, 1), opnum, type,
  4554.                     ind_levels);
  4555.           }
  4556.       }
  4557.  
  4558.     else if (code0 == REG)
  4559.       {
  4560.         find_reloads_address_1 (orig_op0, 1, &XEXP (x, 0), opnum, type,
  4561.                     ind_levels);
  4562.         find_reloads_address_1 (orig_op1, 0, &XEXP (x, 1), opnum, type,
  4563.                     ind_levels);
  4564.       }
  4565.  
  4566.     else if (code1 == REG)
  4567.       {
  4568.         find_reloads_address_1 (orig_op1, 1, &XEXP (x, 1), opnum, type,
  4569.                     ind_levels);
  4570.         find_reloads_address_1 (orig_op0, 0, &XEXP (x, 0), opnum, type,
  4571.                     ind_levels);
  4572.       }
  4573.       }
  4574.  
  4575.       return 0;
  4576.  
  4577.     case POST_INC:
  4578.     case POST_DEC:
  4579.     case PRE_INC:
  4580.     case PRE_DEC:
  4581.       if (GET_CODE (XEXP (x, 0)) == REG)
  4582.     {
  4583.       register int regno = REGNO (XEXP (x, 0));
  4584.       int value = 0;
  4585.       rtx x_orig = x;
  4586.  
  4587.       /* A register that is incremented cannot be constant!  */
  4588.       if (regno >= FIRST_PSEUDO_REGISTER
  4589.           && reg_equiv_constant[regno] != 0)
  4590.         abort ();
  4591.  
  4592.       /* Handle a register that is equivalent to a memory location
  4593.          which cannot be addressed directly.  */
  4594.       if (reg_equiv_address[regno] != 0)
  4595.         {
  4596.           rtx tem = make_memloc (XEXP (x, 0), regno);
  4597.           /* First reload the memory location's address.  */
  4598.           find_reloads_address (GET_MODE (tem), 0, XEXP (tem, 0),
  4599.                     &XEXP (tem, 0), opnum, type, ind_levels);
  4600.           /* Put this inside a new increment-expression.  */
  4601.           x = gen_rtx (GET_CODE (x), GET_MODE (x), tem);
  4602.           /* Proceed to reload that, as if it contained a register.  */
  4603.         }
  4604.  
  4605.       /* If we have a hard register that is ok as an index,
  4606.          don't make a reload.  If an autoincrement of a nice register
  4607.          isn't "valid", it must be that no autoincrement is "valid".
  4608.          If that is true and something made an autoincrement anyway,
  4609.          this must be a special context where one is allowed.
  4610.          (For example, a "push" instruction.)
  4611.          We can't improve this address, so leave it alone.  */
  4612.  
  4613.       /* Otherwise, reload the autoincrement into a suitable hard reg
  4614.          and record how much to increment by.  */
  4615.  
  4616.       if (reg_renumber[regno] >= 0)
  4617.         regno = reg_renumber[regno];
  4618.       if ((regno >= FIRST_PSEUDO_REGISTER
  4619.            || !(context ? REGNO_OK_FOR_INDEX_P (regno)
  4620.             : REGNO_OK_FOR_BASE_P (regno))))
  4621.         {
  4622.           register rtx link;
  4623.  
  4624.           int reloadnum
  4625.         = push_reload (x, NULL_RTX, loc, NULL_PTR,
  4626.                    context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  4627.                    GET_MODE (x), GET_MODE (x), VOIDmode, 0,
  4628.                    opnum, type);
  4629.           reload_inc[reloadnum]
  4630.         = find_inc_amount (PATTERN (this_insn), XEXP (x_orig, 0));
  4631.  
  4632.           value = 1;
  4633.  
  4634. #ifdef AUTO_INC_DEC
  4635.           /* Update the REG_INC notes.  */
  4636.  
  4637.           for (link = REG_NOTES (this_insn);
  4638.            link; link = XEXP (link, 1))
  4639.         if (REG_NOTE_KIND (link) == REG_INC
  4640.             && REGNO (XEXP (link, 0)) == REGNO (XEXP (x_orig, 0)))
  4641.           push_replacement (&XEXP (link, 0), reloadnum, VOIDmode);
  4642. #endif
  4643.         }
  4644.       return value;
  4645.     }
  4646.  
  4647.       else if (GET_CODE (XEXP (x, 0)) == MEM)
  4648.     {
  4649.       /* This is probably the result of a substitution, by eliminate_regs,
  4650.          of an equivalent address for a pseudo that was not allocated to a
  4651.          hard register.  Verify that the specified address is valid and
  4652.          reload it into a register.  */
  4653.       rtx tem = XEXP (x, 0);
  4654.       register rtx link;
  4655.       int reloadnum;
  4656.  
  4657.       /* Since we know we are going to reload this item, don't decrement
  4658.          for the indirection level.
  4659.  
  4660.          Note that this is actually conservative:  it would be slightly
  4661.          more efficient to use the value of SPILL_INDIRECT_LEVELS from
  4662.          reload1.c here.  */
  4663.       find_reloads_address (GET_MODE (x), &XEXP (x, 0),
  4664.                 XEXP (XEXP (x, 0), 0), &XEXP (XEXP (x, 0), 0),
  4665.                 opnum, type, ind_levels);
  4666.  
  4667.       reloadnum = push_reload (x, NULL_RTX, loc, NULL_PTR,
  4668.                    context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  4669.                    GET_MODE (x), VOIDmode, 0, 0, opnum, type);
  4670.       reload_inc[reloadnum]
  4671.         = find_inc_amount (PATTERN (this_insn), XEXP (x, 0));
  4672.  
  4673.       link = FIND_REG_INC_NOTE (this_insn, tem);
  4674.       if (link != 0)
  4675.         push_replacement (&XEXP (link, 0), reloadnum, VOIDmode);
  4676.  
  4677.       return 1;
  4678.     }
  4679.       return 0;
  4680.  
  4681.     case MEM:
  4682.       /* This is probably the result of a substitution, by eliminate_regs, of
  4683.      an equivalent address for a pseudo that was not allocated to a hard
  4684.      register.  Verify that the specified address is valid and reload it
  4685.      into a register.
  4686.  
  4687.      Since we know we are going to reload this item, don't decrement for
  4688.      the indirection level.
  4689.  
  4690.      Note that this is actually conservative:  it would be slightly more
  4691.      efficient to use the value of SPILL_INDIRECT_LEVELS from
  4692.      reload1.c here.  */
  4693.  
  4694.       find_reloads_address (GET_MODE (x), loc, XEXP (x, 0), &XEXP (x, 0),
  4695.                 opnum, type, ind_levels);
  4696.       push_reload (*loc, NULL_RTX, loc, NULL_PTR,
  4697.            context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  4698.            GET_MODE (x), VOIDmode, 0, 0, opnum, type);
  4699.       return 1;
  4700.  
  4701.     case REG:
  4702.       {
  4703.     register int regno = REGNO (x);
  4704.  
  4705.     if (reg_equiv_constant[regno] != 0)
  4706.       {
  4707.         find_reloads_address_part (reg_equiv_constant[regno], loc, 
  4708.                        (context ? INDEX_REG_CLASS
  4709.                     : BASE_REG_CLASS),
  4710.                        GET_MODE (x), opnum, type, ind_levels);
  4711.         return 1;
  4712.       }
  4713.  
  4714. #if 0 /* This might screw code in reload1.c to delete prior output-reload
  4715.      that feeds this insn.  */
  4716.     if (reg_equiv_mem[regno] != 0)
  4717.       {
  4718.         push_reload (reg_equiv_mem[regno], NULL_RTX, loc, NULL_PTR,
  4719.              context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  4720.              GET_MODE (x), VOIDmode, 0, 0, opnum, type);
  4721.         return 1;
  4722.       }
  4723. #endif
  4724.  
  4725.     if (reg_equiv_address[regno] != 0)
  4726.       {
  4727.         x = make_memloc (x, regno);
  4728.         find_reloads_address (GET_MODE (x), 0, XEXP (x, 0), &XEXP (x, 0),
  4729.                   opnum, type, ind_levels);
  4730.       }
  4731.  
  4732.     if (reg_renumber[regno] >= 0)
  4733.       regno = reg_renumber[regno];
  4734.  
  4735.     if ((regno >= FIRST_PSEUDO_REGISTER
  4736.          || !(context ? REGNO_OK_FOR_INDEX_P (regno)
  4737.           : REGNO_OK_FOR_BASE_P (regno))))
  4738.       {
  4739.         push_reload (x, NULL_RTX, loc, NULL_PTR,
  4740.              context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  4741.              GET_MODE (x), VOIDmode, 0, 0, opnum, type);
  4742.         return 1;
  4743.       }
  4744.  
  4745.     /* If a register appearing in an address is the subject of a CLOBBER
  4746.        in this insn, reload it into some other register to be safe.
  4747.        The CLOBBER is supposed to make the register unavailable
  4748.        from before this insn to after it.  */
  4749.     if (regno_clobbered_p (regno, this_insn))
  4750.       {
  4751.         push_reload (x, NULL_RTX, loc, NULL_PTR,
  4752.              context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  4753.              GET_MODE (x), VOIDmode, 0, 0, opnum, type);
  4754.         return 1;
  4755.       }
  4756.       }
  4757.       return 0;
  4758.  
  4759.     case SUBREG:
  4760.       /* If this is a SUBREG of a hard register and the resulting register is
  4761.      of the wrong class, reload the whole SUBREG.  This avoids needless
  4762.      copies if SUBREG_REG is multi-word.  */
  4763.       if (GET_CODE (SUBREG_REG (x)) == REG
  4764.       && REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER)
  4765.     {
  4766.       int regno = REGNO (SUBREG_REG (x)) + SUBREG_WORD (x);
  4767.  
  4768.       if (! (context ? REGNO_OK_FOR_INDEX_P (regno)
  4769.          : REGNO_OK_FOR_BASE_P (regno)))
  4770.         {
  4771.           push_reload (x, NULL_RTX, loc, NULL_PTR,
  4772.                context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  4773.                GET_MODE (x), VOIDmode, 0, 0, opnum, type);
  4774.           return 1;
  4775.         }
  4776.     }
  4777.       break;
  4778.     }
  4779.  
  4780.   {
  4781.     register char *fmt = GET_RTX_FORMAT (code);
  4782.     register int i;
  4783.  
  4784.     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  4785.       {
  4786.     if (fmt[i] == 'e')
  4787.       find_reloads_address_1 (XEXP (x, i), context, &XEXP (x, i),
  4788.                   opnum, type, ind_levels);
  4789.       }
  4790.   }
  4791.  
  4792.   return 0;
  4793. }
  4794.  
  4795. /* X, which is found at *LOC, is a part of an address that needs to be
  4796.    reloaded into a register of class CLASS.  If X is a constant, or if
  4797.    X is a PLUS that contains a constant, check that the constant is a
  4798.    legitimate operand and that we are supposed to be able to load
  4799.    it into the register.
  4800.  
  4801.    If not, force the constant into memory and reload the MEM instead.
  4802.  
  4803.    MODE is the mode to use, in case X is an integer constant.
  4804.  
  4805.    OPNUM and TYPE describe the purpose of any reloads made.
  4806.  
  4807.    IND_LEVELS says how many levels of indirect addressing this machine
  4808.    supports.  */
  4809.  
  4810. static void
  4811. find_reloads_address_part (x, loc, class, mode, opnum, type, ind_levels)
  4812.      rtx x;
  4813.      rtx *loc;
  4814.      enum reg_class class;
  4815.      enum machine_mode mode;
  4816.      int opnum;
  4817.      enum reload_type type;
  4818.      int ind_levels;
  4819. {
  4820.   if (CONSTANT_P (x)
  4821.       && (! LEGITIMATE_CONSTANT_P (x)
  4822.       || PREFERRED_RELOAD_CLASS (x, class) == NO_REGS))
  4823.     {
  4824.       rtx tem = x = force_const_mem (mode, x);
  4825.       find_reloads_address (mode, &tem, XEXP (tem, 0), &XEXP (tem, 0),
  4826.                 opnum, type, ind_levels);
  4827.     }
  4828.  
  4829.   else if (GET_CODE (x) == PLUS
  4830.        && CONSTANT_P (XEXP (x, 1))
  4831.        && (! LEGITIMATE_CONSTANT_P (XEXP (x, 1))
  4832.            || PREFERRED_RELOAD_CLASS (XEXP (x, 1), class) == NO_REGS))
  4833.     {
  4834.       rtx tem = force_const_mem (GET_MODE (x), XEXP (x, 1));
  4835.  
  4836.       x = gen_rtx (PLUS, GET_MODE (x), XEXP (x, 0), tem);
  4837.       find_reloads_address (mode, &tem, XEXP (tem, 0), &XEXP (tem, 0),
  4838.                 opnum, type, ind_levels);
  4839.     }
  4840.  
  4841.   push_reload (x, NULL_RTX, loc, NULL_PTR, class,
  4842.            mode, VOIDmode, 0, 0, opnum, type);
  4843. }
  4844.  
  4845. /* Substitute into the current INSN the registers into which we have reloaded
  4846.    the things that need reloading.  The array `replacements'
  4847.    says contains the locations of all pointers that must be changed
  4848.    and says what to replace them with.
  4849.  
  4850.    Return the rtx that X translates into; usually X, but modified.  */
  4851.  
  4852. void
  4853. subst_reloads ()
  4854. {
  4855.   register int i;
  4856.  
  4857.   for (i = 0; i < n_replacements; i++)
  4858.     {
  4859.       register struct replacement *r = &replacements[i];
  4860.       register rtx reloadreg = reload_reg_rtx[r->what];
  4861.       if (reloadreg)
  4862.     {
  4863.       /* Encapsulate RELOADREG so its machine mode matches what
  4864.          used to be there.  Note that gen_lowpart_common will
  4865.          do the wrong thing if RELOADREG is multi-word.  RELOADREG
  4866.          will always be a REG here.  */
  4867.       if (GET_MODE (reloadreg) != r->mode && r->mode != VOIDmode)
  4868.         reloadreg = gen_rtx (REG, r->mode, REGNO (reloadreg));
  4869.  
  4870.       /* If we are putting this into a SUBREG and RELOADREG is a
  4871.          SUBREG, we would be making nested SUBREGs, so we have to fix
  4872.          this up.  Note that r->where == &SUBREG_REG (*r->subreg_loc).  */
  4873.  
  4874.       if (r->subreg_loc != 0 && GET_CODE (reloadreg) == SUBREG)
  4875.         {
  4876.           if (GET_MODE (*r->subreg_loc)
  4877.           == GET_MODE (SUBREG_REG (reloadreg)))
  4878.         *r->subreg_loc = SUBREG_REG (reloadreg);
  4879.           else
  4880.         {
  4881.           *r->where = SUBREG_REG (reloadreg);
  4882.           SUBREG_WORD (*r->subreg_loc) += SUBREG_WORD (reloadreg);
  4883.         }
  4884.         }
  4885.       else
  4886.         *r->where = reloadreg;
  4887.     }
  4888.       /* If reload got no reg and isn't optional, something's wrong.  */
  4889.       else if (! reload_optional[r->what])
  4890.     abort ();
  4891.     }
  4892. }
  4893.  
  4894. /* Make a copy of any replacements being done into X and move those copies
  4895.    to locations in Y, a copy of X.  We only look at the highest level of
  4896.    the RTL.  */
  4897.  
  4898. void
  4899. copy_replacements (x, y)
  4900.      rtx x;
  4901.      rtx y;
  4902. {
  4903.   int i, j;
  4904.   enum rtx_code code = GET_CODE (x);
  4905.   char *fmt = GET_RTX_FORMAT (code);
  4906.   struct replacement *r;
  4907.  
  4908.   /* We can't support X being a SUBREG because we might then need to know its
  4909.      location if something inside it was replaced.  */
  4910.   if (code == SUBREG)
  4911.     abort ();
  4912.  
  4913.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  4914.     if (fmt[i] == 'e')
  4915.       for (j = 0; j < n_replacements; j++)
  4916.     {
  4917.       if (replacements[j].subreg_loc == &XEXP (x, i))
  4918.         {
  4919.           r = &replacements[n_replacements++];
  4920.           r->where = replacements[j].where;
  4921.           r->subreg_loc = &XEXP (y, i);
  4922.           r->what = replacements[j].what;
  4923.           r->mode = replacements[j].mode;
  4924.         }
  4925.       else if (replacements[j].where == &XEXP (x, i))
  4926.         {
  4927.           r = &replacements[n_replacements++];
  4928.           r->where = &XEXP (y, i);
  4929.           r->subreg_loc = 0;
  4930.           r->what = replacements[j].what;
  4931.           r->mode = replacements[j].mode;
  4932.         }
  4933.     }
  4934. }
  4935.  
  4936. /* If LOC was scheduled to be replaced by something, return the replacement.
  4937.    Otherwise, return *LOC.  */
  4938.  
  4939. rtx
  4940. find_replacement (loc)
  4941.      rtx *loc;
  4942. {
  4943.   struct replacement *r;
  4944.  
  4945.   for (r = &replacements[0]; r < &replacements[n_replacements]; r++)
  4946.     {
  4947.       rtx reloadreg = reload_reg_rtx[r->what];
  4948.  
  4949.       if (reloadreg && r->where == loc)
  4950.     {
  4951.       if (r->mode != VOIDmode && GET_MODE (reloadreg) != r->mode)
  4952.         reloadreg = gen_rtx (REG, r->mode, REGNO (reloadreg));
  4953.  
  4954.       return reloadreg;
  4955.     }
  4956.       else if (reloadreg && r->subreg_loc == loc)
  4957.     {
  4958.       /* RELOADREG must be either a REG or a SUBREG.
  4959.  
  4960.          ??? Is it actually still ever a SUBREG?  If so, why?  */
  4961.  
  4962.       if (GET_CODE (reloadreg) == REG)
  4963.         return gen_rtx (REG, GET_MODE (*loc),
  4964.                 REGNO (reloadreg) + SUBREG_WORD (*loc));
  4965.       else if (GET_MODE (reloadreg) == GET_MODE (*loc))
  4966.         return reloadreg;
  4967.       else
  4968.         return gen_rtx (SUBREG, GET_MODE (*loc), SUBREG_REG (reloadreg),
  4969.                 SUBREG_WORD (reloadreg) + SUBREG_WORD (*loc));
  4970.     }
  4971.     }
  4972.  
  4973.   return *loc;
  4974. }
  4975.  
  4976. /* Return nonzero if register in range [REGNO, ENDREGNO)
  4977.    appears either explicitly or implicitly in X
  4978.    other than being stored into (except for earlyclobber operands).
  4979.  
  4980.    References contained within the substructure at LOC do not count.
  4981.    LOC may be zero, meaning don't ignore anything.
  4982.  
  4983.    This is similar to refers_to_regno_p in rtlanal.c except that we
  4984.    look at equivalences for pseudos that didn't get hard registers.  */
  4985.  
  4986. int
  4987. refers_to_regno_for_reload_p (regno, endregno, x, loc)
  4988.      int regno, endregno;
  4989.      rtx x;
  4990.      rtx *loc;
  4991. {
  4992.   register int i;
  4993.   register RTX_CODE code;
  4994.   register char *fmt;
  4995.  
  4996.   if (x == 0)
  4997.     return 0;
  4998.  
  4999.  repeat:
  5000.   code = GET_CODE (x);
  5001.  
  5002.   switch (code)
  5003.     {
  5004.     case REG:
  5005.       i = REGNO (x);
  5006.  
  5007.       /* If this is a pseudo, a hard register must not have been allocated.
  5008.      X must therefore either be a constant or be in memory.  */
  5009.       if (i >= FIRST_PSEUDO_REGISTER)
  5010.     {
  5011.       if (reg_equiv_memory_loc[i])
  5012.         return refers_to_regno_for_reload_p (regno, endregno,
  5013.                          reg_equiv_memory_loc[i],
  5014.                          NULL_PTR);
  5015.  
  5016.       if (reg_equiv_constant[i])
  5017.         return 0;
  5018.  
  5019.       abort ();
  5020.     }
  5021.  
  5022.       return (endregno > i
  5023.           && regno < i + (i < FIRST_PSEUDO_REGISTER 
  5024.                   ? HARD_REGNO_NREGS (i, GET_MODE (x))
  5025.                   : 1));
  5026.  
  5027.     case SUBREG:
  5028.       /* If this is a SUBREG of a hard reg, we can see exactly which
  5029.      registers are being modified.  Otherwise, handle normally.  */
  5030.       if (GET_CODE (SUBREG_REG (x)) == REG
  5031.       && REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER)
  5032.     {
  5033.       int inner_regno = REGNO (SUBREG_REG (x)) + SUBREG_WORD (x);
  5034.       int inner_endregno
  5035.         = inner_regno + (inner_regno < FIRST_PSEUDO_REGISTER
  5036.                  ? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1);
  5037.  
  5038.       return endregno > inner_regno && regno < inner_endregno;
  5039.     }
  5040.       break;
  5041.  
  5042.     case CLOBBER:
  5043.     case SET:
  5044.       if (&SET_DEST (x) != loc
  5045.       /* Note setting a SUBREG counts as referring to the REG it is in for
  5046.          a pseudo but not for hard registers since we can
  5047.          treat each word individually.  */
  5048.       && ((GET_CODE (SET_DEST (x)) == SUBREG
  5049.            && loc != &SUBREG_REG (SET_DEST (x))
  5050.            && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG
  5051.            && REGNO (SUBREG_REG (SET_DEST (x))) >= FIRST_PSEUDO_REGISTER
  5052.            && refers_to_regno_for_reload_p (regno, endregno,
  5053.                         SUBREG_REG (SET_DEST (x)),
  5054.                         loc))
  5055.           /* If the ouput is an earlyclobber operand, this is
  5056.          a conflict.  */
  5057.           || ((GET_CODE (SET_DEST (x)) != REG
  5058.            || earlyclobber_operand_p (SET_DEST (x)))
  5059.           && refers_to_regno_for_reload_p (regno, endregno,
  5060.                            SET_DEST (x), loc))))
  5061.     return 1;
  5062.  
  5063.       if (code == CLOBBER || loc == &SET_SRC (x))
  5064.     return 0;
  5065.       x = SET_SRC (x);
  5066.       goto repeat;
  5067.     }
  5068.  
  5069.   /* X does not match, so try its subexpressions.  */
  5070.  
  5071.   fmt = GET_RTX_FORMAT (code);
  5072.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  5073.     {
  5074.       if (fmt[i] == 'e' && loc != &XEXP (x, i))
  5075.     {
  5076.       if (i == 0)
  5077.         {
  5078.           x = XEXP (x, 0);
  5079.           goto repeat;
  5080.         }
  5081.       else
  5082.         if (refers_to_regno_for_reload_p (regno, endregno,
  5083.                           XEXP (x, i), loc))
  5084.           return 1;
  5085.     }
  5086.       else if (fmt[i] == 'E')
  5087.     {
  5088.       register int j;
  5089.       for (j = XVECLEN (x, i) - 1; j >=0; j--)
  5090.         if (loc != &XVECEXP (x, i, j)
  5091.         && refers_to_regno_for_reload_p (regno, endregno,
  5092.                          XVECEXP (x, i, j), loc))
  5093.           return 1;
  5094.     }
  5095.     }
  5096.   return 0;
  5097. }
  5098.  
  5099. /* Nonzero if modifying X will affect IN.  If X is a register or a SUBREG,
  5100.    we check if any register number in X conflicts with the relevant register
  5101.    numbers.  If X is a constant, return 0.  If X is a MEM, return 1 iff IN
  5102.    contains a MEM (we don't bother checking for memory addresses that can't
  5103.    conflict because we expect this to be a rare case. 
  5104.  
  5105.    This function is similar to reg_overlap_mention_p in rtlanal.c except
  5106.    that we look at equivalences for pseudos that didn't get hard registers.  */
  5107.  
  5108. int
  5109. reg_overlap_mentioned_for_reload_p (x, in)
  5110.      rtx x, in;
  5111. {
  5112.   int regno, endregno;
  5113.  
  5114.   if (GET_CODE (x) == SUBREG)
  5115.     {
  5116.       regno = REGNO (SUBREG_REG (x));
  5117.       if (regno < FIRST_PSEUDO_REGISTER)
  5118.     regno += SUBREG_WORD (x);
  5119.     }
  5120.   else if (GET_CODE (x) == REG)
  5121.     {
  5122.       regno = REGNO (x);
  5123.  
  5124.       /* If this is a pseudo, it must not have been assigned a hard register.
  5125.      Therefore, it must either be in memory or be a constant.  */
  5126.  
  5127.       if (regno >= FIRST_PSEUDO_REGISTER)
  5128.     {
  5129.       if (reg_equiv_memory_loc[regno])
  5130.         return refers_to_mem_for_reload_p (in);
  5131.       else if (reg_equiv_constant[regno])
  5132.         return 0;
  5133.       abort ();
  5134.     }
  5135.     }
  5136.   else if (CONSTANT_P (x))
  5137.     return 0;
  5138.   else if (GET_CODE (x) == MEM)
  5139.     return refers_to_mem_for_reload_p (in);
  5140.   else if (GET_CODE (x) == SCRATCH || GET_CODE (x) == PC
  5141.        || GET_CODE (x) == CC0)
  5142.     return reg_mentioned_p (x, in);
  5143.   else
  5144.     abort ();
  5145.  
  5146.   endregno = regno + (regno < FIRST_PSEUDO_REGISTER
  5147.               ? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1);
  5148.  
  5149.   return refers_to_regno_for_reload_p (regno, endregno, in, NULL_PTR);
  5150. }
  5151.  
  5152. /* Return nonzero if anything in X contains a MEM.  Look also for pseudo
  5153.    registers.  */
  5154.  
  5155. int
  5156. refers_to_mem_for_reload_p (x)
  5157.      rtx x;
  5158. {
  5159.   char *fmt;
  5160.   int i;
  5161.  
  5162.   if (GET_CODE (x) == MEM)
  5163.     return 1;
  5164.  
  5165.   if (GET_CODE (x) == REG)
  5166.     return (REGNO (x) >= FIRST_PSEUDO_REGISTER
  5167.         && reg_equiv_memory_loc[REGNO (x)]);
  5168.             
  5169.   fmt = GET_RTX_FORMAT (GET_CODE (x));
  5170.   for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
  5171.     if (fmt[i] == 'e'
  5172.     && (GET_CODE (XEXP (x, i)) == MEM
  5173.         || refers_to_mem_for_reload_p (XEXP (x, i))))
  5174.       return 1;
  5175.   
  5176.   return 0;
  5177. }
  5178.  
  5179. /* Check the insns before INSN to see if there is a suitable register
  5180.    containing the same value as GOAL.
  5181.    If OTHER is -1, look for a register in class CLASS.
  5182.    Otherwise, just see if register number OTHER shares GOAL's value.
  5183.  
  5184.    Return an rtx for the register found, or zero if none is found.
  5185.  
  5186.    If RELOAD_REG_P is (short *)1,
  5187.    we reject any hard reg that appears in reload_reg_rtx
  5188.    because such a hard reg is also needed coming into this insn.
  5189.  
  5190.    If RELOAD_REG_P is any other nonzero value,
  5191.    it is a vector indexed by hard reg number
  5192.    and we reject any hard reg whose element in the vector is nonnegative
  5193.    as well as any that appears in reload_reg_rtx.
  5194.  
  5195.    If GOAL is zero, then GOALREG is a register number; we look
  5196.    for an equivalent for that register.
  5197.  
  5198.    MODE is the machine mode of the value we want an equivalence for.
  5199.    If GOAL is nonzero and not VOIDmode, then it must have mode MODE.
  5200.  
  5201.    This function is used by jump.c as well as in the reload pass.
  5202.  
  5203.    If GOAL is the sum of the stack pointer and a constant, we treat it
  5204.    as if it were a constant except that sp is required to be unchanging.  */
  5205.  
  5206. rtx
  5207. find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
  5208.      register rtx goal;
  5209.      rtx insn;
  5210.      enum reg_class class;
  5211.      register int other;
  5212.      short *reload_reg_p;
  5213.      int goalreg;
  5214.      enum machine_mode mode;
  5215. {
  5216.   register rtx p = insn;
  5217.   rtx goaltry, valtry, value, where;
  5218.   register rtx pat;
  5219.   register int regno = -1;
  5220.   int valueno;
  5221.   int goal_mem = 0;
  5222.   int goal_const = 0;
  5223.   int goal_mem_addr_varies = 0;
  5224.   int need_stable_sp = 0;
  5225.   int nregs;
  5226.   int valuenregs;
  5227.  
  5228.   if (goal == 0)
  5229.     regno = goalreg;
  5230.   else if (GET_CODE (goal) == REG)
  5231.     regno = REGNO (goal);
  5232.   else if (GET_CODE (goal) == MEM)
  5233.     {
  5234.       enum rtx_code code = GET_CODE (XEXP (goal, 0));
  5235.       if (MEM_VOLATILE_P (goal))
  5236.     return 0;
  5237.       if (flag_float_store && GET_MODE_CLASS (GET_MODE (goal)) == MODE_FLOAT)
  5238.     return 0;
  5239.       /* An address with side effects must be reexecuted.  */
  5240.       switch (code)
  5241.     {
  5242.     case POST_INC:
  5243.     case PRE_INC:
  5244.     case POST_DEC:
  5245.     case PRE_DEC:
  5246.       return 0;
  5247.     }
  5248.       goal_mem = 1;
  5249.     }
  5250.   else if (CONSTANT_P (goal))
  5251.     goal_const = 1;
  5252.   else if (GET_CODE (goal) == PLUS
  5253.        && XEXP (goal, 0) == stack_pointer_rtx
  5254.        && CONSTANT_P (XEXP (goal, 1)))
  5255.     goal_const = need_stable_sp = 1;
  5256.   else
  5257.     return 0;
  5258.  
  5259.   /* On some machines, certain regs must always be rejected
  5260.      because they don't behave the way ordinary registers do.  */
  5261.   
  5262. #ifdef OVERLAPPING_REGNO_P
  5263.    if (regno >= 0 && regno < FIRST_PSEUDO_REGISTER
  5264.        && OVERLAPPING_REGNO_P (regno))
  5265.      return 0;
  5266. #endif      
  5267.  
  5268.   /* Scan insns back from INSN, looking for one that copies
  5269.      a value into or out of GOAL.
  5270.      Stop and give up if we reach a label.  */
  5271.  
  5272.   while (1)
  5273.     {
  5274.       p = PREV_INSN (p);
  5275.       if (p == 0 || GET_CODE (p) == CODE_LABEL)
  5276.     return 0;
  5277.       if (GET_CODE (p) == INSN
  5278.       /* If we don't want spill regs ... */
  5279.       && (! (reload_reg_p != 0
  5280.          && reload_reg_p != (short *) (HOST_WIDE_INT) 1)
  5281.       /* ... then ignore insns introduced by reload; they aren't useful
  5282.          and can cause results in reload_as_needed to be different
  5283.          from what they were when calculating the need for spills.
  5284.          If we notice an input-reload insn here, we will reject it below,
  5285.          but it might hide a usable equivalent.  That makes bad code.
  5286.          It may even abort: perhaps no reg was spilled for this insn
  5287.          because it was assumed we would find that equivalent.  */
  5288.           || INSN_UID (p) < reload_first_uid))
  5289.     {
  5290.       rtx tem;
  5291.       pat = single_set (p);
  5292.       /* First check for something that sets some reg equal to GOAL.  */
  5293.       if (pat != 0
  5294.           && ((regno >= 0
  5295.            && true_regnum (SET_SRC (pat)) == regno
  5296.            && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
  5297.           ||
  5298.           (regno >= 0
  5299.            && true_regnum (SET_DEST (pat)) == regno
  5300.            && (valueno = true_regnum (valtry = SET_SRC (pat))) >= 0)
  5301.           ||
  5302.           (goal_const && rtx_equal_p (SET_SRC (pat), goal)
  5303.            && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
  5304.           || (goal_mem
  5305.               && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0
  5306.               && rtx_renumbered_equal_p (goal, SET_SRC (pat)))
  5307.           || (goal_mem
  5308.               && (valueno = true_regnum (valtry = SET_SRC (pat))) >= 0
  5309.               && rtx_renumbered_equal_p (goal, SET_DEST (pat)))
  5310.           /* If we are looking for a constant,
  5311.              and something equivalent to that constant was copied
  5312.              into a reg, we can use that reg.  */
  5313.           || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
  5314.                               NULL_RTX))
  5315.               && rtx_equal_p (XEXP (tem, 0), goal)
  5316.               && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
  5317.           || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
  5318.                               NULL_RTX))
  5319.               && GET_CODE (SET_DEST (pat)) == REG
  5320.               && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
  5321.               && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT
  5322.               && GET_CODE (goal) == CONST_INT
  5323.               && 0 != (goaltry = operand_subword (XEXP (tem, 0), 0, 0,
  5324.                               VOIDmode))
  5325.               && rtx_equal_p (goal, goaltry)
  5326.               && (valtry = operand_subword (SET_DEST (pat), 0, 0,
  5327.                             VOIDmode))
  5328.               && (valueno = true_regnum (valtry)) >= 0)
  5329.           || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
  5330.                               NULL_RTX))
  5331.               && GET_CODE (SET_DEST (pat)) == REG
  5332.               && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
  5333.               && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT
  5334.               && GET_CODE (goal) == CONST_INT
  5335.               && 0 != (goaltry = operand_subword (XEXP (tem, 0), 1, 0,
  5336.                               VOIDmode))
  5337.               && rtx_equal_p (goal, goaltry)
  5338.               && (valtry
  5339.               = operand_subword (SET_DEST (pat), 1, 0, VOIDmode))
  5340.               && (valueno = true_regnum (valtry)) >= 0)))
  5341.         if (other >= 0
  5342.         ? valueno == other
  5343.         : ((unsigned) valueno < FIRST_PSEUDO_REGISTER
  5344.            && TEST_HARD_REG_BIT (reg_class_contents[(int) class],
  5345.                      valueno)))
  5346.           {
  5347.         value = valtry;
  5348.         where = p;
  5349.         break;
  5350.           }
  5351.     }
  5352.     }
  5353.  
  5354.   /* We found a previous insn copying GOAL into a suitable other reg VALUE
  5355.      (or copying VALUE into GOAL, if GOAL is also a register).
  5356.      Now verify that VALUE is really valid.  */
  5357.  
  5358.   /* VALUENO is the register number of VALUE; a hard register.  */
  5359.  
  5360.   /* Don't try to re-use something that is killed in this insn.  We want
  5361.      to be able to trust REG_UNUSED notes.  */
  5362.   if (find_reg_note (where, REG_UNUSED, value))
  5363.     return 0;
  5364.  
  5365.   /* If we propose to get the value from the stack pointer or if GOAL is
  5366.      a MEM based on the stack pointer, we need a stable SP.  */
  5367.   if (valueno == STACK_POINTER_REGNUM
  5368.       || (goal_mem && reg_overlap_mentioned_for_reload_p (stack_pointer_rtx,
  5369.                               goal)))
  5370.     need_stable_sp = 1;
  5371.  
  5372.   /* Reject VALUE if the copy-insn moved the wrong sort of datum.  */
  5373.   if (GET_MODE (value) != mode)
  5374.     return 0;
  5375.  
  5376.   /* Reject VALUE if it was loaded from GOAL
  5377.      and is also a register that appears in the address of GOAL.  */
  5378.  
  5379.   if (goal_mem && value == SET_DEST (PATTERN (where))
  5380.       && refers_to_regno_for_reload_p (valueno,
  5381.                        (valueno
  5382.                     + HARD_REGNO_NREGS (valueno, mode)),
  5383.                        goal, NULL_PTR))
  5384.     return 0;
  5385.  
  5386.   /* Reject registers that overlap GOAL.  */
  5387.  
  5388.   if (!goal_mem && !goal_const
  5389.       && regno + HARD_REGNO_NREGS (regno, mode) > valueno
  5390.       && regno < valueno + HARD_REGNO_NREGS (valueno, mode))
  5391.     return 0;
  5392.  
  5393.   /* Reject VALUE if it is one of the regs reserved for reloads.
  5394.      Reload1 knows how to reuse them anyway, and it would get
  5395.      confused if we allocated one without its knowledge.
  5396.      (Now that insns introduced by reload are ignored above,
  5397.      this case shouldn't happen, but I'm not positive.)  */
  5398.  
  5399.   if (reload_reg_p != 0 && reload_reg_p != (short *) (HOST_WIDE_INT) 1
  5400.       && reload_reg_p[valueno] >= 0)
  5401.     return 0;
  5402.  
  5403.   /* On some machines, certain regs must always be rejected
  5404.      because they don't behave the way ordinary registers do.  */
  5405.   
  5406. #ifdef OVERLAPPING_REGNO_P
  5407.   if (OVERLAPPING_REGNO_P (valueno))
  5408.     return 0;
  5409. #endif      
  5410.  
  5411.   nregs = HARD_REGNO_NREGS (regno, mode);
  5412.   valuenregs = HARD_REGNO_NREGS (valueno, mode);
  5413.  
  5414.   /* Reject VALUE if it is a register being used for an input reload
  5415.      even if it is not one of those reserved.  */
  5416.  
  5417.   if (reload_reg_p != 0)
  5418.     {
  5419.       int i;
  5420.       for (i = 0; i < n_reloads; i++)
  5421.     if (reload_reg_rtx[i] != 0 && reload_in[i])
  5422.       {
  5423.         int regno1 = REGNO (reload_reg_rtx[i]);
  5424.         int nregs1 = HARD_REGNO_NREGS (regno1,
  5425.                        GET_MODE (reload_reg_rtx[i]));
  5426.         if (regno1 < valueno + valuenregs
  5427.         && regno1 + nregs1 > valueno)
  5428.           return 0;
  5429.       }
  5430.     }
  5431.  
  5432.   if (goal_mem)
  5433.     /* We must treat frame pointer as varying here,
  5434.        since it can vary--in a nonlocal goto as generated by expand_goto.  */
  5435.     goal_mem_addr_varies = !CONSTANT_ADDRESS_P (XEXP (goal, 0));
  5436.  
  5437.   /* Now verify that the values of GOAL and VALUE remain unaltered
  5438.      until INSN is reached.  */
  5439.  
  5440.   p = insn;
  5441.   while (1)
  5442.     {
  5443.       p = PREV_INSN (p);
  5444.       if (p == where)
  5445.     return value;
  5446.  
  5447.       /* Don't trust the conversion past a function call
  5448.      if either of the two is in a call-clobbered register, or memory.  */
  5449.       if (GET_CODE (p) == CALL_INSN
  5450.       && ((regno >= 0 && regno < FIRST_PSEUDO_REGISTER
  5451.            && call_used_regs[regno])
  5452.           ||
  5453.           (valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER
  5454.            && call_used_regs[valueno])
  5455.           ||
  5456.           goal_mem
  5457.           || need_stable_sp))
  5458.     return 0;
  5459.  
  5460. #ifdef INSN_CLOBBERS_REGNO_P
  5461.       if ((valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER
  5462.       && INSN_CLOBBERS_REGNO_P (p, valueno))
  5463.       || (regno >= 0 && regno < FIRST_PSEUDO_REGISTER
  5464.       && INSN_CLOBBERS_REGNO_P (p, regno)))
  5465.     return 0;
  5466. #endif
  5467.  
  5468.       if (GET_RTX_CLASS (GET_CODE (p)) == 'i')
  5469.     {
  5470.       /* If this insn P stores in either GOAL or VALUE, return 0.
  5471.          If GOAL is a memory ref and this insn writes memory, return 0.
  5472.          If GOAL is a memory ref and its address is not constant,
  5473.          and this insn P changes a register used in GOAL, return 0.  */
  5474.  
  5475.       pat = PATTERN (p);
  5476.       if (GET_CODE (pat) == SET || GET_CODE (pat) == CLOBBER)
  5477.         {
  5478.           register rtx dest = SET_DEST (pat);
  5479.           while (GET_CODE (dest) == SUBREG
  5480.              || GET_CODE (dest) == ZERO_EXTRACT
  5481.              || GET_CODE (dest) == SIGN_EXTRACT
  5482.              || GET_CODE (dest) == STRICT_LOW_PART)
  5483.         dest = XEXP (dest, 0);
  5484.           if (GET_CODE (dest) == REG)
  5485.         {
  5486.           register int xregno = REGNO (dest);
  5487.           int xnregs;
  5488.           if (REGNO (dest) < FIRST_PSEUDO_REGISTER)
  5489.             xnregs = HARD_REGNO_NREGS (xregno, GET_MODE (dest));
  5490.           else
  5491.             xnregs = 1;
  5492.           if (xregno < regno + nregs && xregno + xnregs > regno)
  5493.             return 0;
  5494.           if (xregno < valueno + valuenregs
  5495.               && xregno + xnregs > valueno)
  5496.             return 0;
  5497.           if (goal_mem_addr_varies
  5498.               && reg_overlap_mentioned_for_reload_p (dest, goal))
  5499.             return 0;
  5500.         }
  5501.           else if (goal_mem && GET_CODE (dest) == MEM
  5502.                && ! push_operand (dest, GET_MODE (dest)))
  5503.         return 0;
  5504.           else if (need_stable_sp && push_operand (dest, GET_MODE (dest)))
  5505.         return 0;
  5506.         }
  5507.       else if (GET_CODE (pat) == PARALLEL)
  5508.         {
  5509.           register int i;
  5510.           for (i = XVECLEN (pat, 0) - 1; i >= 0; i--)
  5511.         {
  5512.           register rtx v1 = XVECEXP (pat, 0, i);
  5513.           if (GET_CODE (v1) == SET || GET_CODE (v1) == CLOBBER)
  5514.             {
  5515.               register rtx dest = SET_DEST (v1);
  5516.               while (GET_CODE (dest) == SUBREG
  5517.                  || GET_CODE (dest) == ZERO_EXTRACT
  5518.                  || GET_CODE (dest) == SIGN_EXTRACT
  5519.                  || GET_CODE (dest) == STRICT_LOW_PART)
  5520.             dest = XEXP (dest, 0);
  5521.               if (GET_CODE (dest) == REG)
  5522.             {
  5523.               register int xregno = REGNO (dest);
  5524.               int xnregs;
  5525.               if (REGNO (dest) < FIRST_PSEUDO_REGISTER)
  5526.                 xnregs = HARD_REGNO_NREGS (xregno, GET_MODE (dest));
  5527.               else
  5528.                 xnregs = 1;
  5529.               if (xregno < regno + nregs
  5530.                   && xregno + xnregs > regno)
  5531.                 return 0;
  5532.               if (xregno < valueno + valuenregs
  5533.                   && xregno + xnregs > valueno)
  5534.                 return 0;
  5535.               if (goal_mem_addr_varies
  5536.                   && reg_overlap_mentioned_for_reload_p (dest,
  5537.                                      goal))
  5538.                 return 0;
  5539.             }
  5540.               else if (goal_mem && GET_CODE (dest) == MEM
  5541.                    && ! push_operand (dest, GET_MODE (dest)))
  5542.             return 0;
  5543.               else if (need_stable_sp
  5544.                    && push_operand (dest, GET_MODE (dest)))
  5545.             return 0;
  5546.             }
  5547.         }
  5548.         }
  5549.  
  5550. #ifdef AUTO_INC_DEC
  5551.       /* If this insn auto-increments or auto-decrements
  5552.          either regno or valueno, return 0 now.
  5553.          If GOAL is a memory ref and its address is not constant,
  5554.          and this insn P increments a register used in GOAL, return 0.  */
  5555.       {
  5556.         register rtx link;
  5557.  
  5558.         for (link = REG_NOTES (p); link; link = XEXP (link, 1))
  5559.           if (REG_NOTE_KIND (link) == REG_INC
  5560.           && GET_CODE (XEXP (link, 0)) == REG)
  5561.         {
  5562.           register int incno = REGNO (XEXP (link, 0));
  5563.           if (incno < regno + nregs && incno >= regno)
  5564.             return 0;
  5565.           if (incno < valueno + valuenregs && incno >= valueno)
  5566.             return 0;
  5567.           if (goal_mem_addr_varies
  5568.               && reg_overlap_mentioned_for_reload_p (XEXP (link, 0),
  5569.                                  goal))
  5570.             return 0;
  5571.         }
  5572.       }
  5573. #endif
  5574.     }
  5575.     }
  5576. }
  5577.  
  5578. /* Find a place where INCED appears in an increment or decrement operator
  5579.    within X, and return the amount INCED is incremented or decremented by.
  5580.    The value is always positive.  */
  5581.  
  5582. static int
  5583. find_inc_amount (x, inced)
  5584.      rtx x, inced;
  5585. {
  5586.   register enum rtx_code code = GET_CODE (x);
  5587.   register char *fmt;
  5588.   register int i;
  5589.  
  5590.   if (code == MEM)
  5591.     {
  5592.       register rtx addr = XEXP (x, 0);
  5593.       if ((GET_CODE (addr) == PRE_DEC
  5594.        || GET_CODE (addr) == POST_DEC
  5595.        || GET_CODE (addr) == PRE_INC
  5596.        || GET_CODE (addr) == POST_INC)
  5597.       && XEXP (addr, 0) == inced)
  5598.     return GET_MODE_SIZE (GET_MODE (x));
  5599.     }
  5600.  
  5601.   fmt = GET_RTX_FORMAT (code);
  5602.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  5603.     {
  5604.       if (fmt[i] == 'e')
  5605.     {
  5606.       register int tem = find_inc_amount (XEXP (x, i), inced);
  5607.       if (tem != 0)
  5608.         return tem;
  5609.     }
  5610.       if (fmt[i] == 'E')
  5611.     {
  5612.       register int j;
  5613.       for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  5614.         {
  5615.           register int tem = find_inc_amount (XVECEXP (x, i, j), inced);
  5616.           if (tem != 0)
  5617.         return tem;
  5618.         }
  5619.     }
  5620.     }
  5621.  
  5622.   return 0;
  5623. }
  5624.  
  5625. /* Return 1 if register REGNO is the subject of a clobber in insn INSN.  */
  5626.  
  5627. int
  5628. regno_clobbered_p (regno, insn)
  5629.      int regno;
  5630.      rtx insn;
  5631. {
  5632.   if (GET_CODE (PATTERN (insn)) == CLOBBER
  5633.       && GET_CODE (XEXP (PATTERN (insn), 0)) == REG)
  5634.     return REGNO (XEXP (PATTERN (insn), 0)) == regno;
  5635.  
  5636.   if (GET_CODE (PATTERN (insn)) == PARALLEL)
  5637.     {
  5638.       int i = XVECLEN (PATTERN (insn), 0) - 1;
  5639.  
  5640.       for (; i >= 0; i--)
  5641.     {
  5642.       rtx elt = XVECEXP (PATTERN (insn), 0, i);
  5643.       if (GET_CODE (elt) == CLOBBER && GET_CODE (XEXP (elt, 0)) == REG
  5644.           && REGNO (XEXP (elt, 0)) == regno)
  5645.         return 1;
  5646.     }
  5647.     }
  5648.  
  5649.   return 0;
  5650. }
  5651.